libDwm-0.9.45
DwmSysLogger.hh File Reference

Dwm::SysLogger class definition and Syslog() macro. More...

#include <errno.h>
#include <stdarg.h>
#include <syslog.h>
#include <cstdio>
#include <version>
#include <mutex>
#include <source_location>
#include <string>
#include "DwmPortability.hh"
#include <format>
Include dependency graph for DwmSysLogger.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Macros

#define Syslog(...)    Dwm::SysLogger::Log(std::source_location::current(),__VA_ARGS__)
 Used just like syslog(), but calls Dwm::SysLogger::Log() to allow the filename, line number and function name to be logged automatically and the priority tag text provided by Dwm::SysLogger.
 
#define FSyslog(...)    Dwm::SysLogger::FmtLog(std::source_location::current(),__VA_ARGS__)
 Like Syslog() but the format string (second argument) is a std::format format string.
 

Detailed Description

Dwm::SysLogger class definition and Syslog() macro.

Macro Definition Documentation

◆ FSyslog

#define FSyslog ( ...)     Dwm::SysLogger::FmtLog(std::source_location::current(),__VA_ARGS__)

Like Syslog() but the format string (second argument) is a std::format format string.

Unfortunately some of the popular Linux distributions are way behind on a libstdc++ that has <format>. It's May 26, 2024 and Ubuntu 24.04 and Raspberry Pi 12 (bookwork) don't have the C++20 features that are needed. On such platforms, I use libfmt instead.

◆ Syslog

#define Syslog ( ...)     Dwm::SysLogger::Log(std::source_location::current(),__VA_ARGS__)

Used just like syslog(), but calls Dwm::SysLogger::Log() to allow the filename, line number and function name to be logged automatically and the priority tag text provided by Dwm::SysLogger.

Note this requires variadic macros, but g++ and clang++ support them.