This library is designed to create and run state graphs. It supports hierarchical states and parallel states execution.
StateMachineLib/source/Logger.cpp@4:22b4462fcb26, 2021-02-02 (annotated)
- Committer:
- martin13
- Date:
- Tue Feb 02 20:47:45 2021 +0000
- Revision:
- 4:22b4462fcb26
- Parent:
- 0:f4fdca2c4c67
Added unittests
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
martin13 | 0:f4fdca2c4c67 | 1 | #include "Logger.h" |
martin13 | 0:f4fdca2c4c67 | 2 | |
martin13 | 0:f4fdca2c4c67 | 3 | Logger::Logger(int _level){ |
martin13 | 0:f4fdca2c4c67 | 4 | Logger::level = _level; |
martin13 | 0:f4fdca2c4c67 | 5 | } |
martin13 | 0:f4fdca2c4c67 | 6 | |
martin13 | 0:f4fdca2c4c67 | 7 | void Logger::debug(const char* format, ...){ |
martin13 | 0:f4fdca2c4c67 | 8 | |
martin13 | 0:f4fdca2c4c67 | 9 | if (Logger::level == Logger::DEBUG){ |
martin13 | 0:f4fdca2c4c67 | 10 | printf("[DEBUG] : "); |
martin13 | 0:f4fdca2c4c67 | 11 | va_list args; |
martin13 | 0:f4fdca2c4c67 | 12 | va_start(args,format); |
martin13 | 0:f4fdca2c4c67 | 13 | vprintf(format,args); |
martin13 | 0:f4fdca2c4c67 | 14 | va_end(args); |
martin13 | 0:f4fdca2c4c67 | 15 | printf("\n"); |
martin13 | 0:f4fdca2c4c67 | 16 | } |
martin13 | 0:f4fdca2c4c67 | 17 | } |
martin13 | 0:f4fdca2c4c67 | 18 | |
martin13 | 0:f4fdca2c4c67 | 19 | |
martin13 | 0:f4fdca2c4c67 | 20 | void Logger::info(const char* format, ...){ |
martin13 | 0:f4fdca2c4c67 | 21 | |
martin13 | 0:f4fdca2c4c67 | 22 | if (Logger::level <= Logger::INFO){ |
martin13 | 0:f4fdca2c4c67 | 23 | printf("[INFO] : "); |
martin13 | 0:f4fdca2c4c67 | 24 | va_list args; |
martin13 | 0:f4fdca2c4c67 | 25 | va_start(args,format); |
martin13 | 0:f4fdca2c4c67 | 26 | vprintf(format,args); |
martin13 | 0:f4fdca2c4c67 | 27 | va_end(args); |
martin13 | 0:f4fdca2c4c67 | 28 | printf("\n"); |
martin13 | 0:f4fdca2c4c67 | 29 | } |
martin13 | 0:f4fdca2c4c67 | 30 | } |
martin13 | 0:f4fdca2c4c67 | 31 | |
martin13 | 0:f4fdca2c4c67 | 32 | void Logger::warn(const char* format, ...){ |
martin13 | 0:f4fdca2c4c67 | 33 | |
martin13 | 0:f4fdca2c4c67 | 34 | if (Logger::level <= Logger::WARNING){ |
martin13 | 0:f4fdca2c4c67 | 35 | printf("[WARN] : "); |
martin13 | 0:f4fdca2c4c67 | 36 | va_list args; |
martin13 | 0:f4fdca2c4c67 | 37 | va_start(args,format); |
martin13 | 0:f4fdca2c4c67 | 38 | vprintf(format,args); |
martin13 | 0:f4fdca2c4c67 | 39 | va_end(args); |
martin13 | 0:f4fdca2c4c67 | 40 | printf("\n"); |
martin13 | 0:f4fdca2c4c67 | 41 | } |
martin13 | 0:f4fdca2c4c67 | 42 | } |
martin13 | 0:f4fdca2c4c67 | 43 | |
martin13 | 0:f4fdca2c4c67 | 44 | void Logger::err(const char* format, ...){ |
martin13 | 0:f4fdca2c4c67 | 45 | |
martin13 | 0:f4fdca2c4c67 | 46 | if (Logger::level <= Logger::ERROR){ |
martin13 | 0:f4fdca2c4c67 | 47 | printf("[ERROR] : "); |
martin13 | 0:f4fdca2c4c67 | 48 | va_list args; |
martin13 | 0:f4fdca2c4c67 | 49 | va_start(args,format); |
martin13 | 0:f4fdca2c4c67 | 50 | vprintf(format,args); |
martin13 | 0:f4fdca2c4c67 | 51 | va_end(args); |
martin13 | 0:f4fdca2c4c67 | 52 | printf("\n"); |
martin13 | 0:f4fdca2c4c67 | 53 | } |
martin13 | 0:f4fdca2c4c67 | 54 | } |
martin13 | 0:f4fdca2c4c67 | 55 | |
martin13 | 0:f4fdca2c4c67 | 56 | int Logger::level = Logger::DEBUG; |