41#ifndef _DWMSYSLOGGER_HH_
42#define _DWMSYSLOGGER_HH_
53#include <source_location>
58#if (defined DWM_HAVE_STD_FORMAT)
61 #if (defined DWM_HAVE_LIBFMT)
62 #include <fmt/format.h>
92 static bool Open(
const char *ident,
int logopt,
int facility);
100 static bool Open(
const char *ident,
int logopt,
101 const std::string & facility);
115 static bool Log(
int priority,
const char *message, ...);
122 static bool Log(
const std::string & filename,
int lineno,
123 const std::string & function,
int priority,
124 const char *message, ...);
130 static bool Log(std::source_location loc,
int priority,
131 const char *message, ...);
133#if (defined DWM_HAVE_STD_FORMAT)
137 template <
typename ...Args>
138 static bool FmtLog(std::source_location loc,
int priority,
139 std::format_string<Args...> fm,
147 return Log(loc, priority,
148 std::format(fm, std::forward<Args>(args)...).c_str());
151#elif (defined DWM_HAVE_LIBFMT)
155 template <
typename ...Args>
156 static bool FmtLog(std::source_location loc,
int priority,
157 fmt::format_string<Args...> fm,
165 return Log(loc, priority,
166 fmt::format(fm, std::forward<Args>(args)...).c_str());
174 static bool VaLog(
int priority,
const std::string & message,
183 static bool VaLog(
const std::string & filename,
int lineno,
184 const std::string & function,
int priority,
185 const std::string & message, va_list & vaList);
266 static std::mutex _mutex;
268 static int _logOptions;
269 static std::string _ident;
270 static int _logFacility;
271 static bool _showPriorities;
272 static bool _showFunction;
273 static bool _showFileLocation;
274 static int _minimumPriority;
286 Dwm::SysLogger::Log(std::source_location::current(),__VA_ARGS__)
295#if (defined DWM_HAVE_STD_FORMAT || defined DWM_HAVE_LIBFMT)
296 #define FSyslog(...) \
297 Dwm::SysLogger::FmtLog(std::source_location::current(),__VA_ARGS__)
A configure target for dealing with OS differences.
This class encapsulates syslog logging in global scope (all members are static).
Definition DwmSysLogger.hh:73
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,...
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,...
static bool Open(const char *ident, int logopt, int facility)
Opens the logger for syslog logging.
static std::string PriorityTag(int priority)
Returns the priority tag ("[F]", "[W]", et.
static bool ShowPriorities(bool showPriorities)
If showPriorities is true, the logger will tag each log message with an indication of the message's p...
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 calle...
static bool ShowPriorities()
If the logger is set to show priorities in each log message, returns true.
static bool ShowFileLocation()
If the logger is set to show file location information in Log(const std::string &,...
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 mus...
static int MinimumPriority(const std::string &minimumPriority)
Sets and returns the lowest message priority that the logger will log.
static int MinimumPriority()
Returns the lowest message priority that the logger will log.
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 ShowFunction(bool showFunction)
If showFunction is true, the logger will show function information in each log message logged with Lo...
static int PriorityValue(const std::string &name)
Returns the priority value for the given priority name.
static bool ShowFileLocation(bool showFileLocation)
If showFileLocation is true, the logger will show the file and line number information in each log me...
static bool ShowFunction()
If the logger is set to show function information in Log(const string &, int, const string &,...
static int MinimumPriority(int minimumPriority)
Sets and returns the lowest message priority that the logger will log.
static bool Close()
Closes the logger.