My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros
logging.h File Reference

Logging of status messages to the terminal. More...

#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <pthread.h>

Go to the source code of this file.

Macros

#define ANSI_COLOR_RED   "\x1b[31m"
 
#define ANSI_COLOR_GREEN   "\x1b[32m"
 
#define ANSI_COLOR_YELLOW   "\x1b[33m"
 
#define ANSI_COLOR_BLUE   "\x1b[34m"
 
#define ANSI_COLOR_RESET   "\x1b[0m"
 
#define ANSI_COLOR_PURPLE   "\x1b[35m"
 
#define PICO_SUPPORT_NDEBUG
 
#define LOG_FD   stderr
 Where logs are printed to. More...
 
#define LOG_ALL   0
 
#define log_at_level(lvl_label, color, fd, fmt,...)
 Macro utilized by all loggers. More...
 
#define log_debug(...)
 Use of log_debug(fmt, ...) is not recommended. More...
 
#define debug(fmt,...)   log_debug(__VA_ARGS__)
 
#define log_info(fmt,...)
 
#define log_error(fmt,...)
 
#define log_perror(fmt,...)
 
#define log_warn(fmt,...)
 
#define log_critical(fmt,...)
 
#define log(level, fmt,...)
 Log at a custom level. More...
 
#define log_profile(...)
 
#define tcp_dbg(...)
 

Detailed Description

Logging of status messages to the terminal.

The DeDOS logger supports five built-in log levels (debug, info, error, warn, and critical), in addition to custom log levels.

To enable a custom log level, simply write: log(LOG_SOMETHING, "Stuff to %s", log);

If the macro LOG_SOMETHING is defined, "Stuff to log" will be output. Otherwise, it will be compiled away (if optimization > 0).

Definition in file logging.h.

Macro Definition Documentation

#define ANSI_COLOR_BLUE   "\x1b[34m"

Definition at line 46 of file logging.h.

#define ANSI_COLOR_GREEN   "\x1b[32m"

Definition at line 44 of file logging.h.

#define ANSI_COLOR_PURPLE   "\x1b[35m"

Definition at line 48 of file logging.h.

#define ANSI_COLOR_RED   "\x1b[31m"

Definition at line 43 of file logging.h.

#define ANSI_COLOR_RESET   "\x1b[0m"

Definition at line 47 of file logging.h.

#define ANSI_COLOR_YELLOW   "\x1b[33m"

Definition at line 45 of file logging.h.

#define debug (   fmt,
  ... 
)    log_debug(__VA_ARGS__)

Definition at line 78 of file logging.h.

#define log (   level,
  fmt,
  ... 
)

Log at a custom level.

Compiled away if LOG_CUSTOM is not defined, and optimized out if the preprocessor macro level is not defined (and optimization level is sufficiently high)

Definition at line 147 of file logging.h.

#define LOG_ALL   0

Definition at line 58 of file logging.h.

#define log_at_level (   lvl_label,
  color,
  fd,
  fmt,
  ... 
)
Value:
fprintf(fd, "" color "%lu:%s:%d:%s(): " lvl_label ": " fmt ANSI_COLOR_RESET "\n", \
pthread_self(), __FILE__, __LINE__, __func__, ##__VA_ARGS__)
#define ANSI_COLOR_RESET
Definition: logging.h:47

Macro utilized by all loggers.

Definition at line 65 of file logging.h.

#define log_critical (   fmt,
  ... 
)

Definition at line 124 of file logging.h.

#define log_debug (   ...)

Use of log_debug(fmt, ...) is not recommended.

Use log(LVL, fmt, ...) below

Definition at line 76 of file logging.h.

#define log_error (   fmt,
  ... 
)

Definition at line 101 of file logging.h.

#define LOG_FD   stderr

Where logs are printed to.

Definition at line 53 of file logging.h.

#define log_info (   fmt,
  ... 
)

Definition at line 88 of file logging.h.

#define log_perror (   fmt,
  ... 
)

Definition at line 102 of file logging.h.

#define log_profile (   ...)

Definition at line 156 of file logging.h.

#define log_warn (   fmt,
  ... 
)

Definition at line 113 of file logging.h.

#define PICO_SUPPORT_NDEBUG

Definition at line 50 of file logging.h.

#define tcp_dbg (   ...)

Definition at line 165 of file logging.h.