LCOV - code coverage report
Current view: top level - core/src/log - log.h Hit Total Coverage
Test: ROOT-Sim master Documentation Coverage Lines: 14 15 93.3 %
Date: 2021-03-25 15:11:55

          Line data    Source code
       1           1 : /**
       2             :  * @file log/log.h
       3             :  *
       4             :  * @brief Logging library
       5             :  *
       6             :  * This library can be used to produce logs during simulation runs.
       7             :  *
       8             :  * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com>
       9             :  * SPDX-License-Identifier: GPL-3.0-only
      10             :  */
      11             : #pragma once
      12             : 
      13             : #include <stdbool.h>
      14             : 
      15             : #ifndef LOG_LEVEL
      16             : /// The minimum logging level supported at compile time
      17             : /** Compiler optimizations remove log calls with lower level than this one */
      18           1 : #define LOG_LEVEL LOG_TRACE
      19             : #endif
      20             : 
      21           0 : #define LOG_CAN_LOG_AT_BUILD(l) (l >= LOG_LEVEL)
      22             : 
      23           1 : extern int log_level;
      24           1 : extern bool log_colored;
      25             : 
      26             : /// The logging level reserved to very low priority messages
      27           1 : #define LOG_TRACE       0
      28             : /// The logging level reserved to useful debug messages
      29           1 : #define LOG_DEBUG       1
      30             : /// The logging level reserved to useful runtime messages
      31           1 : #define LOG_INFO        2
      32             : /// The logging level reserved to unexpected, non deal breaking conditions
      33           1 : #define LOG_WARN        3
      34             : /// The logging level reserved to unexpected, problematic conditions
      35           1 : #define LOG_ERROR       4
      36             : /// The logging level reserved to unexpected, fatal conditions
      37           1 : #define LOG_FATAL       5
      38             : 
      39             : /**
      40             :  * @brief Checks if a logging level is being processed
      41             :  * @param lvl the logging level to check
      42             :  * @return true if @a level is being process, false otherwise
      43             :  */
      44           1 : #define log_can_log(lvl) ((lvl) >= LOG_LEVEL && (lvl) >= log_level)
      45             : 
      46             : /**
      47             :  * @brief Produces a log
      48             :  * @param lvl the logging level associated to the message
      49             :  * @param ... a printf-style format string followed by its arguments if needed
      50             :  */
      51           1 : #define log_log(lvl, ...)                                               \
      52             :         do {                                                            \
      53             :                 if(log_can_log(lvl))                                    \
      54             :                         _log_log(lvl, __FILE__, __LINE__, __VA_ARGS__); \
      55             :         } while(0)
      56             : 
      57           1 : void _log_log(int level, const char *file, unsigned line, const char *fmt, ...);
      58             : 
      59           1 : void log_logo_print(void);

Generated by: LCOV version 1.14