tools:logger:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:logger:start [2017/02/03 11:21] – graf | tools:logger:start [2020/11/26 13:06] (current) – [Default LogWriter] ursgraf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Logging ====== | ====== Logging ====== | ||
- | A logger enables a user to gather information about the state of the system at runtime. | + | A logger enables a user to gather information about the state of the system at runtime. |
+ | <code cpp> | ||
+ | Logger:: | ||
+ | Logger log = Logger:: | ||
+ | | ||
+ | log.info() << " | ||
+ | int a = 298; | ||
+ | log.warn() << "a = " << a; | ||
+ | log.error() << "first line" << endl << " | ||
+ | </ | ||
+ | A logger can log its output to one of several '' | ||
+ | While declaring a logger you can choose a category for it which is a single capital letter, see below: | ||
+ | <code cpp> | ||
+ | Logger log1 = Logger:: | ||
+ | Logger log2 = Logger:: | ||
+ | </ | ||
- | + | ===== Log Levels | |
- | ===== How it works ===== | + | A logger knows one of five severity levels. |
- | The most important function | + | * TRACE: lowest level |
+ | * INFO | ||
+ | * WARN | ||
+ | * ERROR | ||
+ | * FATAL: highest level | ||
+ | Every '' | ||
<code cpp> | <code cpp> | ||
- | | + | |
+ | </ | ||
+ | This would enable levels WARN, ERROR and FATAL. \\ | ||
+ | If you do not specify a certain level the default level is INFO. If you want to see all messages you have to use '' | ||
- | // 1) Read inputs and check them | + | ===== Default LogWriter ===== |
- | for(auto ia : level-> | + | The EEROS library itself used several loggers, e.g. the safety system and the executor both log certain states and transitions. In order to see those generated messages it is necessary to specify a default '' |
- | if(ia != nullptr) ia-> | + | |
- | } | + | <code cpp> |
- | + | | |
- | // 2) Execute level action | + | |
- | if(level->action != nullptr) level-> | + | |
- | + | ||
- | // 3) Set outputs | + | |
- | for(auto oa : level-> | + | |
- | if(oa != nullptr) oa->set(); | + | |
- | } | + | |
- | } | + | |
</ | </ | ||
+ | If you forget to assign a default logger, you will not get logging information from components of the library such as the safety system or the executor. | ||
+ | ===== Logging into the Console and into a File ===== | ||
+ | Sometimes it can be desirable to have a logger write to the console and write the same content into a file. This is especially helpful on a embedded system where you start an application remotely (e.g. through //ssh//). In such a case you can define a '' | ||
+ | <code cpp> | ||
+ | Logger:: | ||
+ | </ | ||
+ | A log file will be created at the given location. Its file name will be appended with the current date and time of the creation of the file. |
tools/logger/start.1486117285.txt.gz · Last modified: 2017/02/03 11:21 (external edit)