LCOV - code coverage report
Current view: top level - core/src/log - log.h Hit Total Coverage
Test: ROOT-Sim develop Documentation Coverage Lines: 14 14 100.0 %
Date: 2021-03-02 11:24:52

          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           1 : extern int log_level;
      22           1 : extern bool log_colored;
      23             : 
      24             : /// The logging level reserved to very low priority messages
      25           1 : #define LOG_TRACE       0
      26             : /// The logging level reserved to useful debug messages
      27           1 : #define LOG_DEBUG       1
      28             : /// The logging level reserved to useful runtime messages
      29           1 : #define LOG_INFO        2
      30             : /// The logging level reserved to unexpected, non deal breaking conditions
      31           1 : #define LOG_WARN        3
      32             : /// The logging level reserved to unexpected, problematic conditions
      33           1 : #define LOG_ERROR       4
      34             : /// The logging level reserved to unexpected, fatal conditions
      35           1 : #define LOG_FATAL       5
      36             : 
      37             : /**
      38             :  * @brief Checks if a logging level is being processed
      39             :  * @param lvl the logging level to check
      40             :  * @return true if @a level is being process, false otherwise
      41             :  */
      42           1 : #define log_can_log(lvl) ((lvl) >= LOG_LEVEL && (lvl) >= log_level)
      43             : 
      44             : /**
      45             :  * @brief Produces a log
      46             :  * @param lvl the logging level associated to the message
      47             :  * @param ... a printf-style format string followed by its arguments if needed
      48             :  */
      49           1 : #define log_log(lvl, ...)                                               \
      50             :         do {                                                            \
      51             :                 if(log_can_log(lvl))                                    \
      52             :                         _log_log(lvl, __FILE__, __LINE__, __VA_ARGS__); \
      53             :         } while(0)
      54             : 
      55           1 : void _log_log(int level, const char *file, unsigned line, const char *fmt, ...);
      56             : 
      57           1 : void log_logo_print(void);

Generated by: LCOV version 1.14