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)
| Master Macro (must not be used directly).
#define | SM_LOGEMERG(x)
| Macro for syslog(3) level EMERG.
#define | SM_LOGALERT(x)
| Macro for syslog(3) level ALERT.
#define | SM_LOGCRIT(x)
| Macro for syslog(3) level CRIT.
#define | SM_LOGERR(x)
| Macro for syslog(3) level ERR.
#define | SM_LOGWARNING(x)
| Macro for syslog(3) level WARNING.
#define | SM_LOGNOTICE(x)
| Macro for syslog(3) level NOTICE.
#define | SM_LOGINFO(x)
| Macro for syslog(3) level INFO.
#define | SM_LOGDEBUG(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

## Macro Definition Documentation

## SM_LOG

#define SM_LOG | ( |  | l,
|  |  | p,
|  |  | x )

Value:
UI::Util::SysLogMonoSingleton::log(l) << p << ": " << x << " [" SM_LOGADD << "]." << std::endl
SM_LOGADD
#define SM_LOGADD
Add this text to every log messages.
Definition SMLog.hpp:66
UI::Util::SysLogMonoSingleton::log
static SysLogMono & log(int level)
Log function; you may stream directly into the result.
Definition SysLogMono.cpp:68

Master Macro (must not be used directly).

## SM_LOGALERT

#define SM_LOGALERT | ( |  | x | ) |

Value:
SM_LOG(LOG_ALERT, "ALT", x)
SM_LOG
#define SM_LOG(l, p, x)
Definition SMLog.hpp:88

Macro for syslog(3) level ALERT.

## SM_LOGCRIT

#define SM_LOGCRIT | ( |  | x | ) |

Value:
SM_LOG(LOG_CRIT, "CRT", x)

Macro for syslog(3) level CRIT.

## SM_LOGDEBUG

#define SM_LOGDEBUG | ( |  | x | ) |

Value:
SM_LOG(LOG_DEBUG, "dbg", x)

Macro for syslog(3) level DEBUG.

## SM_LOGEMERG

#define SM_LOGEMERG | ( |  | x | ) |

Value:
SM_LOG(LOG_EMERG, "EMG", x)

Macro for syslog(3) level EMERG.

## SM_LOGERR

#define SM_LOGERR | ( |  | x | ) |

Value:
SM_LOG(LOG_ERR, "ERR", x)

Macro for syslog(3) level ERR.

## SM_LOGINFO

#define SM_LOGINFO | ( |  | x | ) |

Value:
SM_LOG(LOG_INFO, "inf", x)

Macro for syslog(3) level INFO.

## SM_LOGNOTICE

#define SM_LOGNOTICE | ( |  | x | ) |

Value:
SM_LOG(LOG_NOTICE, "ntc", x)

Macro for syslog(3) level NOTICE.

## SM_LOGWARNING

#define SM_LOGWARNING | ( |  | x | ) |

Value:
SM_LOG(LOG_WARNING, "WRN", x)

Macro for syslog(3) level WARNING.