The slog class is used to stream messages to the system's logging facility (syslogd).
More...
Inherits std::streambuf, and std::ostream.
|
enum | Class {
classSecurity
, classAudit
, classDaemon
, classUser
,
classDefault
, classLocal0
, classLocal1
, classLocal2
,
classLocal3
, classLocal4
, classLocal5
, classLocal6
,
classLocal7
} |
|
typedef enum ost::Slog::Class | Class |
|
enum | Level {
levelEmergency = 1
, levelAlert
, levelCritical
, levelError
,
levelWarning
, levelNotice
, levelInfo
, levelDebug
} |
|
typedef enum ost::Slog::Level | Level |
|
|
void | alert (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | alert (void) |
|
void | clogEnable (bool f=true) |
| Enables or disables the echoing of the messages to clog in addition to the syslog daemon.
|
|
void | close (void) |
|
void | critical (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | critical (void) |
|
void | debug (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | debug (void) |
|
void | emerg (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | emerg (void) |
|
void | error (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | error (void) |
|
void | info (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | info (void) |
|
void | level (Level enable) |
| Sets the logging level.
|
|
void | notice (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | notice (void) |
|
void | open (const char *ident, Class grp=classUser) |
| (re)opens the output stream.
|
|
Slog & | operator() (const char *ident, Class grp=classUser, Level level=levelError) |
| Sets the log identifier, level, and class to use for subsequent output.
|
|
Slog & | operator() (Level level, Class grp=classDefault) |
| Changes the log level and class to use for subsequent output.
|
|
Slog & | operator() (void) |
| Does nothing except return *this.
|
|
| Slog (void) |
| Default (and only) constructor.
|
|
void | warn (const char *format,...) |
| Print a formatted syslog string.
|
|
Slog & | warn (void) |
|
The slog class is used to stream messages to the system's logging facility (syslogd).
A default slog
object is used to avoid confusion with the native syslog facility and to imply a logical relationship to the C++ clog()
.
The key difference is that the slog
object sends it's output to the system logging daemon (typically syslogd) rather than through stderr. slog
can be streamed with the <<
operator just like clog
; a default slog object is pre-initialized, and you stream character data to it.
The slog
allows one to specify logging levels and other properties through the ()
operators. Hence, once can do:
slog("mydaemon", SLOG_DAEMON, SLOG_EMERGENCY) << I just died << endl;
or things like:
slog("mydaemon", SLOG_DAEMON);
slog(SLOG_INFO) << "daemon initalized" << endl;
The intent is to be as common-place and as convenient to use as the stderr based clog facility found in C++, and this is especially useful for C++ daemons.
The std::flush
manipulator doesn't work. Either the std::endl
or std::ends
manipulators must be used to cause the output to be sent to the daemon.
When this class is used on a system that doesn't have the syslog headers (i.e. a non-posix win32 box), the output goes to the a file with the same name as the syslog identifier string with '.log' appended to it. If the identifier string ends in '.exe', the '.exe' is removed before the '.log' is appened. (e.g. the identifier foo.exe will generate a log file named foo.log)
- Author
- David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m
Minor docs & hacks by Jon Little littl.nosp@m.ej@a.nosp@m.rlut..nosp@m.utex.nosp@m.as.ed.nosp@m.u
system logging facility class.
Definition at line 104 of file slog.h.