The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
log.h File Reference

Logging library. More...

#include <stdbool.h>
+ Include dependency graph for log.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOG_LEVEL   LOG_TRACE
 The minimum logging level supported at compile time. More...
 
#define LOG_TRACE   0
 The logging level reserved to very low priority messages.
 
#define LOG_DEBUG   1
 The logging level reserved to useful debug messages.
 
#define LOG_INFO   2
 The logging level reserved to useful runtime messages.
 
#define LOG_WARN   3
 The logging level reserved to unexpected, non deal breaking conditions.
 
#define LOG_ERROR   4
 The logging level reserved to unexpected, problematic conditions.
 
#define LOG_FATAL   5
 The logging level reserved to unexpected, fatal conditions.
 
#define log_can_log(lvl)   ((lvl) >= LOG_LEVEL && (lvl) >= log_level)
 Checks if a logging level is being processed. More...
 
#define log_log(lvl, ...)
 Produces a log. More...
 

Functions

void _log_log (int level, const char *file, unsigned line, const char *fmt,...)
 Logs a message. For internal use: log_log() should be used instead. More...
 
void log_logo_print (void)
 Prints a fancy ROOT-Sim logo on the terminal.
 

Variables

int log_level
 The minimum log level of the messages to display.
 
bool log_colored
 If set, uses color codes to color the log outputs.
 

Detailed Description

Logging library.

This library can be used to produce logs during simulation runs.

Definition in file log.h.

Macro Definition Documentation

◆ log_can_log

#define log_can_log (   lvl)    ((lvl) >= LOG_LEVEL && (lvl) >= log_level)

Checks if a logging level is being processed.

Parameters
lvlthe logging level to check
Returns
true if level is being process, false otherwise

Definition at line 42 of file log.h.

◆ LOG_LEVEL

#define LOG_LEVEL   LOG_TRACE

The minimum logging level supported at compile time.

Compiler optimizations remove log calls with lower level than this one

Definition at line 18 of file log.h.

◆ log_log

#define log_log (   lvl,
  ... 
)
Value:
do { \
if(log_can_log(lvl)) \
_log_log(lvl, __FILE__, __LINE__, __VA_ARGS__); \
} while(0)

Produces a log.

Parameters
lvlthe logging level associated to the message
...a printf-style format string followed by its arguments if needed

Definition at line 49 of file log.h.

Function Documentation

◆ _log_log()

void _log_log ( int  level,
const char *  file,
unsigned  line,
const char *  fmt,
  ... 
)

Logs a message. For internal use: log_log() should be used instead.

Parameters
levelthe importance level of the message to log
filethe file name where this function is being called
linethe line number where this function is being called
fmta printf-style format string for the message to log
...the list of arguments to fill in the format string fmt

Definition at line 44 of file log.c.

log_can_log
#define log_can_log(lvl)
Checks if a logging level is being processed.
Definition: log.h:42