tools:logger:start
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tools:logger:start [2017/02/03 11:15] – created graf | tools:logger:start [2020/11/26 13:06] (current) – [Default LogWriter] ursgraf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Logging ====== | ====== Logging ====== | ||
- | The safety system is key to the EEROS framework. It regulates all interaction with the HAL (Hardware Abstraction Layer) and uses a safety level to determine | + | A logger enables |
- | All critical hardware inputs are read and all critical hardware outputs are driven by the safety system. So called //safety levels// exactly define in which state a robot can be. Such a level could be // | + | <code cpp> |
+ | Logger:: | ||
+ | Logger log = Logger:: | ||
+ | |||
+ | log.info() << " | ||
+ | int a = 298; | ||
+ | log.warn() << "a = " << a; | ||
+ | log.error() << "first line" << endl << " | ||
+ | </code> | ||
+ | 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:: | ||
+ | </ | ||
- | ===== How it works ===== | + | ===== Log Levels |
- | The most important function | + | A logger knows one of five severity levels. |
+ | * 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.1486116900.txt.gz · Last modified: 2017/02/03 11:15 by graf