IBR-DTNSuite
0.12
|
#include <Logger.h>
Public Types | |
enum | LogOptions { LOG_NONE = 0, LOG_DATETIME = 1 << 0, LOG_HOSTNAME = 1 << 1, LOG_LEVEL = 1 << 2, LOG_TIMESTAMP = 1 << 3, LOG_TAG = 1 << 4 } |
enum | LogLevel { LOGGER_EMERG = 1 << 0, LOGGER_ALERT = 1 << 1, LOGGER_CRIT = 1 << 2, LOGGER_ERR = 1 << 3, LOGGER_WARNING = 1 << 4, LOGGER_NOTICE = 1 << 5, LOGGER_INFO = 1 << 6, LOGGER_DEBUG = 1 << 7, LOGGER_ALL = 0xff } |
Public Member Functions | |
Logger (const Logger &) | |
virtual | ~Logger () |
void | setMessage (const std::string &data) |
const std::string & | str () const |
void | print () |
LogLevel | getLevel () const |
const std::string & | getTag () const |
int | getDebugVerbosity () const |
struct timeval | getLogTime () const |
Static Public Member Functions | |
static Logger | emergency (const std::string &tag) |
static Logger | alert (const std::string &tag) |
static Logger | critical (const std::string &tag) |
static Logger | error (const std::string &tag) |
static Logger | warning (const std::string &tag) |
static Logger | notice (const std::string &tag) |
static Logger | info (const std::string &tag) |
static Logger | debug (const std::string &tag, int verbosity) |
static void | setVerbosity (const int verbosity) |
static unsigned char | getLogMask () |
static int | getVerbosity () |
static void | addStream (std::ostream &stream, const unsigned char logmask=LOGGER_INFO, const unsigned char options=LOG_NONE) |
static void | setLogfile (const ibrcommon::File &logfile, const unsigned char logmask=LOGGER_INFO, const unsigned char options=LOG_NONE) |
static void | enableSyslog (const char *name, int option, int facility, const unsigned char logmask=LOGGER_INFO) |
static void | enableAsync () |
static void | enableBuffer (size_t size) |
static void | writeBuffer (std::ostream &) |
static void | stop () |
static void | setDefaultTag (const std::string &tag) |
static void | reload () |
ibrcommon::Logger::Logger | ( | const Logger & | obj) |
Definition at line 53 of file Logger.cpp.
Referenced by alert(), critical(), debug(), emergency(), error(), info(), notice(), and warning().
|
virtual |
Definition at line 58 of file Logger.cpp.
|
static |
Add a standard output stream to the logging framework.
stream | Standard output stream |
logmask | This mask specify what will be written to this stream. You can combine options with the or function. |
options | This mask specify what will be added to each log message. You can combine options with the or function. |
Definition at line 142 of file Logger.cpp.
References ibrcommon::LogWriter::addStream(), and ibrcommon::LogWriter::getInstance().
Referenced by __daemon_run(), func_sighandler(), and main().
|
static |
Definition at line 77 of file Logger.cpp.
References Logger(), and LOGGER_ALERT.
|
static |
Definition at line 82 of file Logger.cpp.
References Logger(), and LOGGER_CRIT.
|
static |
Definition at line 107 of file Logger.cpp.
References Logger(), and LOGGER_DEBUG.
|
static |
Definition at line 72 of file Logger.cpp.
References Logger(), and LOGGER_EMERG.
|
static |
enable the asynchronous logging This starts a separate thread and a thread-safe queue to queue all logging messages first and call the log routine by the thread. This option is necessary, if the stream to log into are not thread-safe by itself.
Definition at line 420 of file Logger.cpp.
References ibrcommon::LogWriter::enableAsync(), and ibrcommon::LogWriter::getInstance().
Referenced by __daemon_run(), and InitService().
|
static |
Enables the internal ring-buffer.
size | The size of the buffer. |
Definition at line 425 of file Logger.cpp.
References ibrcommon::LogWriter::enableBuffer(), and ibrcommon::LogWriter::getInstance().
Referenced by __daemon_run(), and InitService().
|
static |
Enable logging message to the system syslog.
name | The naming prefix for all log messages. |
option | Syslog specific options. |
facility | Syslog facility. |
logmask | This mask specify what will be written to the syslog. You can combine options with the or function. |
Definition at line 158 of file Logger.cpp.
References ibrcommon::LogWriter::enableSyslog(), and ibrcommon::LogWriter::getInstance().
Referenced by __daemon_run(), main(), and dtn::daemon::NativeDaemon::setLogging().
|
static |
Definition at line 87 of file Logger.cpp.
References Logger(), and LOGGER_ERR.
int ibrcommon::Logger::getDebugVerbosity | ( | ) | const |
Definition at line 475 of file Logger.cpp.
Logger::LogLevel ibrcommon::Logger::getLevel | ( | ) | const |
Return the log level of this Logger
Definition at line 465 of file Logger.cpp.
|
static |
Returns the global logging mask
Definition at line 122 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::LogWriter::getLogMask().
struct timeval ibrcommon::Logger::getLogTime | ( | ) | const |
Return the Log entry of this Logger
Definition at line 480 of file Logger.cpp.
const std::string & ibrcommon::Logger::getTag | ( | ) | const |
Return the TAG of this Logger
Definition at line 470 of file Logger.cpp.
|
static |
Get the global verbosity of the logger.
Definition at line 127 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::LogWriter::getVerbosity().
Referenced by dtn::daemon::Debugger::callbackBundleReceived().
|
static |
Definition at line 102 of file Logger.cpp.
References Logger(), and LOGGER_INFO.
|
static |
Definition at line 97 of file Logger.cpp.
References Logger(), and LOGGER_NOTICE.
void ibrcommon::Logger::print | ( | ) |
Print the log message to the log output (or queue it in the writer)
Definition at line 163 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::LogWriter::log().
|
static |
Reload the logger. This re-opens the logfile for output.
Definition at line 459 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::LogWriter::reload().
Referenced by dtn::daemon::NativeDaemon::reload().
|
static |
Set the default tag for untagged logging
Definition at line 448 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::LogWriter::setDefaultTag().
Referenced by __daemon_run(), and dtn::daemon::NativeDaemon::setLogging().
|
static |
Set the logfile for the logging framework.
logfile | The file to log into. |
logmask | This mask specify what will be written to this stream. You can combine options with the or function. |
options | This mask specify what will be added to each log message. You can combine options with the or function. |
Definition at line 147 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::LogWriter::setLogfile().
Referenced by __daemon_run(), and dtn::daemon::NativeDaemon::setLogFile().
void ibrcommon::Logger::setMessage | ( | const std::string & | data) |
Set the logging message
Definition at line 62 of file Logger.cpp.
|
static |
Set the global verbosity of the logger.
verbosity | A verbosity level as number. Higher value leads to more output. |
Definition at line 112 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::LogWriter::setVerbosity().
Referenced by __daemon_run(), and dtn::daemon::NativeDaemon::setDebug().
|
static |
stops the asynchronous logging thread you need to call this before your program is going down, if you have called enableAsync() before.
Definition at line 453 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), and ibrcommon::JoinableThread::stop().
Referenced by __daemon_run(), and ServiceMain().
const std::string & ibrcommon::Logger::str | ( | ) | const |
Returns the logging message as string
Definition at line 67 of file Logger.cpp.
|
static |
Definition at line 92 of file Logger.cpp.
References Logger(), and LOGGER_WARNING.
|
static |
Write the buffer to a stream
Definition at line 430 of file Logger.cpp.
References ibrcommon::LogWriter::getInstance(), LOG_DATETIME, LOG_LEVEL, LOGGER_ALL, and ibrcommon::LogWriter::writeBuffer().