SMLogMono.hpp File Reference

Syslog Macro Log: Simple logging based on compiler macros and syslog(3) for mono-threaded aplications. More...

`#include <iostream>`
`#include <syslog.h>`
`#include <ui-utilcpp/SysLogMono.hpp>`
Include dependency graph for SMLogMono.hpp:

## Macros

#define | SM_LOGLEVEL LOG_NOTICE
| The Log Level; Log code under this level gets eliminated.
#define | SM_LOGADD __FILE__ << ":" << __LINE__
| Add this text to every log messages.
#define | SM_LOG(l, p, x) UI::Util::SysLogMonoSingleton::log(l) << p << ": " << x << " [" SM_LOGADD << "]." << std::endl
| Master Macro (must not be used directly).
#define | SM_LOGEMERG(x) SM_LOG(LOG_EMERG, "EMG", x)
| Macro for syslog(3) level EMERG.
#define | SM_LOGALERT(x) SM_LOG(LOG_ALERT, "ALT", x)
| Macro for syslog(3) level ALERT.
#define | SM_LOGCRIT(x) SM_LOG(LOG_CRIT, "CRT", x)
| Macro for syslog(3) level CRIT.
#define | SM_LOGERR(x) SM_LOG(LOG_ERR, "ERR", x)
| Macro for syslog(3) level ERR.
#define | SM_LOGWARNING(x) SM_LOG(LOG_WARNING, "WRN", x)
| Macro for syslog(3) level WARNING.
#define | SM_LOGNOTICE(x) SM_LOG(LOG_NOTICE, "ntc", x)
| Macro for syslog(3) level NOTICE.
#define | SM_LOGINFO(x) SM_LOG(LOG_INFO, "inf", x)
| Macro for syslog(3) level INFO.
#define | SM_LOGDEBUG(x) SM_LOG(LOG_DEBUG, "dbg", x)
| Macro for syslog(3) level DEBUG.
Additional debug levels 8-11.
#define | SM_LOGDEBUG1(x)
#define | SM_LOGDEBUG2(x)
#define | SM_LOGDEBUG3(x)
#define | SM_LOGDEBUG4(x)

## Detailed Description

Syslog Macro Log: Simple logging based on compiler macros and syslog(3) for mono-threaded aplications.

Author
  Schlund + Partner AG

See also
  SMLog.hpp

Synopsis:

#include <ui-utilcpp/SMLogMono.hpp>
SMLogMono.hpp
Syslog Macro Log: Simple logging based on compiler macros and syslog(3) for mono-threaded aplications...

This can be used as drop-in replacement for SMLog.hpp, i.e. the source using these logging macros does not need to be changed.

Each prirority level (see syslog(3)) gets its own compiler macro, which can be used rather straightforward in the source; the argument of the macro may include stream piping. For example:

SM_LOGNOTICE("I have noticed something: " << something)

Logs can be turned off at compile time (giving full run time advantage, as the code is removed) with a threshold. Additionally, you can give the facility, and additional text at compile time. For example:

c++ ... -DSM_LOGLEVEL=5 -DSM_LOGADD="getpid()" -DSM_LOGFACILITY="ost::SLOG_USER"

eliminates all log messages with priority higher than 5, giving the process id as additional information

Logging itself is done via SysLogMonoSingleton; it should be configured somewhere at the beginning of your program, for example like:

UI::Util::SysLogMonoSingleton logger("dvdb", LOG_PERROR, LOG_DAEMON);
UI::Util::SysLogMonoSingleton
Singleton class holding one SysLogMono object.
Definition SysLogMono.hpp:55