12 #ifndef ROC_CORE_LOG_H_
13 #define ROC_CORE_LOG_H_
15 #include "roc_core/atomic_ops.h"
17 #include "roc_core/log_backend.h"
24 #error "ROC_MODULE not defined"
31 #define roc_log(level, ...) \
33 ::roc::core::Logger& logger = ::roc::core::Logger::instance(); \
34 if ((level) <= logger.get_level()) { \
35 logger.writef((level), ROC_STRINGIZE(ROC_MODULE), __FILE__, __LINE__, \
151 enum { MaxArgs = 8 };
160 void* handler_args_[MaxArgs];
#define ROC_ATTR_PRINTF(fmt_pos, args_pos)
Function gets printf-like arguments.
static T load_relaxed(const T &var)
Atomic load (no barrier).
void set_handler(LogHandler handler, void **args, size_t n_args)
Set log handler.
LogLevel get_level() const
Get current maximum log level.
void set_verbosity(unsigned)
Set verbosity level.
void writef(LogLevel level, const char *module, const char *file, int line, const char *format,...)
Print message to log.
static Logger & instance()
Get logger instance.
void set_level(LogLevel)
Set maximum log level.
void set_colors(ColorsMode)
Set colors mode.
Base class for non-copyable objects.
static T & instance()
Get singleton instance.
void(* LogHandler)(const LogMessage &message, void **args)
Log handler.
@ ColorsDisabled
Do not use colored logs.
@ ColorsEnabled
Use colored logs.
@ ColorsAuto
Automatically use colored logs if colors are supported.
LocationMode
Location mode.
@ LocationDisabled
Do not show location.
@ LocationEnabled
Show location.
int64_t nanoseconds_t
Nanoseconds.
@ LogNote
Noteworthy debug message.
@ LogNone
Disable all messages.
@ LogDebug
Regular debug message.
@ LogTrace
Extra verbose debug message.
@ LogInfo
Informational message.
ColorsMode colors_mode
Whether to enable colors.
const char * module
Name of module that originated message.
uint64_t pid
Plaform-specific process ID.
uint64_t tid
Plaform-specific thread ID.
LogLevel level
Logging level.
nanoseconds_t time
Timestamp, nanoseconds since Unix epoch.
LocationMode location_mode
Whether to enable location.
const char * file
File path.
const char * text
Message text.