libDwm-0.9.45
Dwm::SysLogger Class Reference

This class encapsulates syslog logging in global scope (all members are static). More...

#include <DwmSysLogger.hh>

Static Public Member Functions

static bool Open (const char *ident, int logopt, int facility)
 Opens the logger for syslog logging.
 
static bool Open (const char *ident, int logopt, const std::string &facility)
 The same as Open() above except the log facility is passed as a const reference to a string which must be one of "user", "daemon", "auth", "local0", "local1", "local2", "local3", "local4", "local5", "local6", or "local7".
 
static bool Close ()
 Closes the logger.
 
static bool Log (int priority, const char *message,...)
 Just like syslog(), takes a priority and a format string and variable list of arguments.
 
static bool Log (const std::string &filename, int lineno, const std::string &function, int priority, const char *message,...)
 Like syslog(), but takes filename, lineno and function arguments which are usually FILE, LINE and PRETTY_FUNCTION in the caller source.
 
static bool Log (std::source_location loc, int priority, const char *message,...)
 Like syslog(), but takes a source_location argument that can be used to log the location of the caller.
 
template<typename ... Args>
static bool FmtLog (std::source_location loc, int priority, std::format_string< Args... > fm, Args &&... args)
 
static bool VaLog (int priority, const std::string &message, va_list &vaList)
 Just like vsyslog(), takes a priority and a format string and a va_list.
 
static bool VaLog (const std::string &filename, int lineno, const std::string &function, int priority, const std::string &message, va_list &vaList)
 Just like vsyslog(), but takes filename, lineno and function arguments which are usually FILE, LINE and PRETTY_FUNCTION in the caller source.
 
static bool ShowPriorities ()
 If the logger is set to show priorities in each log message, returns true.
 
static bool ShowPriorities (bool showPriorities)
 If showPriorities is true, the logger will tag each log message with an indication of the message's priority.
 
static bool ShowFileLocation ()
 If the logger is set to show file location information in Log(const std::string &, int, int, const char *, ...), returns true.
 
static bool ShowFileLocation (bool showFileLocation)
 If showFileLocation is true, the logger will show the file and line number information in each log message logged with Log(const std::string &, int, int, const char *, ...).
 
static bool ShowFunction ()
 If the logger is set to show function information in Log(const string &, int, const string &, int, const char *, ...), returns true.
 
static bool ShowFunction (bool showFunction)
 If showFunction is true, the logger will show function information in each log message logged with Log(const string &, int, const string &, int, const char *, ...).
 
static int MinimumPriority ()
 Returns the lowest message priority that the logger will log.
 
static int MinimumPriority (int minimumPriority)
 Sets and returns the lowest message priority that the logger will log.
 
static int MinimumPriority (const std::string &minimumPriority)
 Sets and returns the lowest message priority that the logger will log.
 
static std::string PriorityTag (int priority)
 Returns the priority tag ("[F]", "[W]", et.
 
static int PriorityValue (const std::string &name)
 Returns the priority value for the given priority name.
 

Detailed Description

This class encapsulates syslog logging in global scope (all members are static).

Member Function Documentation

◆ Close()

static bool Dwm::SysLogger::Close ( )
static

Closes the logger.

Returns true on success, false on failure. Note that this is essentially a no-op. We don't want to call closelog() because we don't want to prevent external syslog() calls.

◆ Log()

static bool Dwm::SysLogger::Log ( int priority,
const char * message,
... )
static

Just like syslog(), takes a priority and a format string and variable list of arguments.

Returns true on success, false on failure.

◆ MinimumPriority() [1/2]

static int Dwm::SysLogger::MinimumPriority ( const std::string & minimumPriority)
static

Sets and returns the lowest message priority that the logger will log.

minimumPriority may be "debug", "info", "notice", "warning", "error", "critical", "alert" or "emergency".

◆ MinimumPriority() [2/2]

static int Dwm::SysLogger::MinimumPriority ( int minimumPriority)
static

Sets and returns the lowest message priority that the logger will log.

By default, all message priorities will be logged (minimum priority == LOG_DEBUG).

◆ Open()

static bool Dwm::SysLogger::Open ( const char * ident,
int logopt,
int facility )
static

Opens the logger for syslog logging.

ident, logopt and facility are used directly to call openlog() (see the syslog(3) manpage). Returns true on success, false on failure. Note that openlog() gives no indication of failure, hence we only return false if we get an unacceptable logopt or facility. The acceptable facilities are LOG_USER, LOG_DAEMON, LOG_AUTH, LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, and LOG_LOCAL7. The acceptable log options are LOG_PID, LOG_CONS and LOG_NDELAY on all systems. LOG_PERROR is accepted on systems which support it. LOG_NOWAIT is accepted on systems which support it (Solaris, for example). Note this member can cause adverse affects on external syslog() calls because syslog facilities are global. That's why all of our members are static.

◆ PriorityTag()

static std::string Dwm::SysLogger::PriorityTag ( int priority)
static

Returns the priority tag ("[F]", "[W]", et.

al.) for a given priority.

◆ ShowFileLocation()

static bool Dwm::SysLogger::ShowFileLocation ( bool showFileLocation)
static

If showFileLocation is true, the logger will show the file and line number information in each log message logged with Log(const std::string &, int, int, const char *, ...).

If showFileLocation is false, the logger will not show file and line number information in log messages.

◆ ShowFunction()

static bool Dwm::SysLogger::ShowFunction ( bool showFunction)
static

If showFunction is true, the logger will show function information in each log message logged with Log(const string &, int, const string &, int, const char *, ...).

If showFunction is false, the logger will not show function information in log messages.

◆ ShowPriorities() [1/2]

static bool Dwm::SysLogger::ShowPriorities ( )
static

If the logger is set to show priorities in each log message, returns true.

Else returns false.

◆ ShowPriorities() [2/2]

static bool Dwm::SysLogger::ShowPriorities ( bool showPriorities)
static

If showPriorities is true, the logger will tag each log message with an indication of the message's priority.

The tags are of the form "[x]" where x is a single letter. Hence we have "[M]" for LOG_EMERG, "[A]" for LOG_ALERT, "[C]" for LOG_CRIT, "[E]" for LOG_ERR, "[W]" for LOG_WARN, "[N]" for LOG_NOTICE, "[I]" for LOG_INFO and "[D]" for LOG_DEBUG. By default, message priorities are not shown.

◆ VaLog() [1/2]

static bool Dwm::SysLogger::VaLog ( const std::string & filename,
int lineno,
const std::string & function,
int priority,
const std::string & message,
va_list & vaList )
static

Just like vsyslog(), but takes filename, lineno and function arguments which are usually FILE, LINE and PRETTY_FUNCTION in the caller source.

Returns true on success, false on failure.

◆ VaLog() [2/2]

static bool Dwm::SysLogger::VaLog ( int priority,
const std::string & message,
va_list & vaList )
static

Just like vsyslog(), takes a priority and a format string and a va_list.

Returns true on success, false on failure.


The documentation for this class was generated from the following file: