forked from Lephenixnoir/fxos
42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
//---
|
|
// fxos.log: Logging functions
|
|
//---
|
|
|
|
#ifndef FXOS_LOG_H
|
|
#define FXOS_LOG_H
|
|
|
|
#include <fxos/util.h>
|
|
|
|
namespace FxOS::Log {
|
|
|
|
/* Message levels, used for masking and statistics */
|
|
#define LEVEL_LOG 0
|
|
#define LEVEL_WRN 1
|
|
#define LEVEL_ERR 4
|
|
|
|
/* Prefixes to set in the call to log() for brevity. The comma is included.
|
|
Typical usage would be log(ERR "logic is inconsistent"). */
|
|
#define LOG LEVEL_LOG,
|
|
#define WRN LEVEL_WRN,
|
|
#define ERR LEVEL_ERR,
|
|
|
|
/* Select the log level */
|
|
void log_setminlevel(int level);
|
|
|
|
/* Get the minimum log level */
|
|
int log_getminlevel();
|
|
|
|
/* General message logger */
|
|
void logmsg(int level, char const *function, std::string message);
|
|
|
|
/* Automatically apply format strings. Also force the first argument to be
|
|
expanded first, since this causes a comma to appear. */
|
|
#define log(level, ...) \
|
|
loghelper(level, __VA_ARGS__)
|
|
#define loghelper(level, fmtstr, ...) \
|
|
FxOS::Log::logmsg(level, __func__, format(fmtstr __VA_OPT__(,)__VA_ARGS__))
|
|
|
|
} /* namespace FxOS::Log */
|
|
|
|
#endif /* FXOS_LOG_H */
|