CoffeePi
Coffee machine control for Raspberry Pi
logger.h
Go to the documentation of this file.
1 /*
2  * logger.h
3  *
4  * Created on: Feb 3, 2016
5  * Author: Philipp Hinz
6  */
7 
8 #ifndef LOGGER_H_
9 #define LOGGER_H_
10 
11 // Logtypes for coloring
12 
13 typedef enum {
14  LOG_INFO = 0,
15  LOG_CAN = 1,
16  LOG_OK = 2,
17  LOG_WARN = 3,
18  LOG_ERROR = 4,
21 
22 // verbosity levels
23 
24 typedef enum {
25  V_NONE = 0,
26  V_BASIC = 1,
27  V_BREW = 2,
28  V_HAL = 3,
29  V_SQL = 4,
30  V_STRIPE = 5,
31  V_SPI = 6,
33 
34 
35 // Colors \o/
36 #define USE_COLORS
37 
38 // List of escape sequences http://ascii-table.com/ansi-escape-sequences.php
39 
40 #ifdef USE_COLORS
41 #define KNRM "\x1B[0m"
42 #define KRED "\x1B[31m"
43 #define KGRN "\x1B[32m"
44 #define KYEL "\x1B[33m"
45 #define KBLU "\x1B[34m"
46 #define KMAG "\x1B[35m"
47 #define KCYN "\x1B[36m"
48 #define KWHT "\x1B[37m"
49 #else
50 #define KNRM
51 #define KRED
52 #define KGRN
53 #define KYEL
54 #define KBLU
55 #define KMAG
56 #define KCYN
57 #define KWHT
58 #endif
59 
60 #define CLEARLINE "\x1B[100D\x1B[1A\x1B[K"
61 #define KBOLD "\x1B[1m"
62 
63 void logger_error( const char* format, ... );
64 void logger_reset();
65 void logger(logger_verbose_t verboselevel, logger_type_t logtype, const char* format, ... );
66 void logger(logger_verbose_t verboselevel, const char* format, ... );
67 
68 #endif /* LOGGER_H_ */
Definition: logger.h:25
Definition: logger.h:30
Definition: logger.h:19
Definition: logger.h:16
logger_type_t
Definition: logger.h:13
Definition: logger.h:26
Definition: logger.h:15
Definition: logger.h:29
Definition: logger.h:27
logger_verbose_t
Definition: logger.h:24
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
Definition: logger.h:31
void logger_error(const char *format,...)
Outputs the printf like formatted message to stderr and colorizes it.
Definition: logger.cpp:38
Definition: logger.h:14
Definition: logger.h:17
void logger_reset()
Resets the logger to prevent the previous line being overdrawn.
Definition: logger.cpp:58
Definition: logger.h:18
Definition: logger.h:28