logger.h
Go to the documentation of this file.
/*
* logger.h
*
* Created on: Feb 3, 2016
* Author: Philipp Hinz
*/
#ifndef LOGGER_H_
#define LOGGER_H_
// Logtypes for coloring
typedef enum {
LOG_INFO = 0,
LOG_CAN = 1,
LOG_OK = 2,
LOG_WARN = 3,
LOG_ERROR = 4,
LOG_ERRORC = 5,
} logger_type_t;
// verbosity levels
typedef enum {
V_NONE = 0,
V_BASIC = 1,
V_BREW = 2,
V_HAL = 3,
V_SQL = 4,
V_STRIPE = 5,
V_SPI = 6,
} logger_verbose_t;
// Colors \o/
#define USE_COLORS
// List of escape sequences http://ascii-table.com/ansi-escape-sequences.php
#ifdef USE_COLORS
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
#else
#define KNRM
#define KRED
#define KGRN
#define KYEL
#define KBLU
#define KMAG
#define KCYN
#define KWHT
#endif
#define CLEARLINE "\x1B[100D\x1B[1A\x1B[K"
#define KBOLD "\x1B[1m"
void logger_error( const char* format, ... );
void logger_reset();
void logger(logger_verbose_t verboselevel, logger_type_t logtype, const char* format, ... );
void logger(logger_verbose_t verboselevel, const char* format, ... );
#endif /* LOGGER_H_ */
V_NONE
Definition: logger.h:25
V_STRIPE
Definition: logger.h:30
LOG_ERRORC
Definition: logger.h:19
LOG_OK
Definition: logger.h:16
logger_type_t
logger_type_t
Definition: logger.h:13
V_BASIC
Definition: logger.h:26
LOG_CAN
Definition: logger.h:15
V_SQL
Definition: logger.h:29
V_BREW
Definition: logger.h:27
logger_verbose_t
logger_verbose_t
Definition: logger.h:24
logger
void logger(logger_verbose_t verboselevel, logger_type_t logtype, const char *format,...)
prints the message to stdout and formats it
Definition: logger.cpp:69
V_SPI
Definition: logger.h:31
logger_error
void logger_error(const char *format,...)
Outputs the printf like formatted message to stderr and colorizes it.
Definition: logger.cpp:38
LOG_INFO
Definition: logger.h:14
LOG_WARN
Definition: logger.h:17
logger_reset
void logger_reset()
Resets the logger to prevent the previous line being overdrawn.
Definition: logger.cpp:58
LOG_ERROR
Definition: logger.h:18
V_HAL
Definition: logger.h:28