carl  24.04
Computer ARithmetic Library
carl-logging.h
Go to the documentation of this file.
1 /**
2  * @file
3  *
4  * A small wrapper that configures logging for carl.
5  * If LOGGING is not set, all logging is disabled.
6  *
7  * Note that this header should *not* be included if you want to use the carl
8  * logging facilities yourself. To do that, include logging.h and create
9  * logging macros like below for your own application.
10  *
11  * If you want to access the internals of the logging, for example to customize
12  * the sinks or the filter, include logging-internals.h
13  */
14 
15 #pragma once
16 
17 #include <iostream>
18 
19 #include "config.h"
20 #include "logging.h"
21 
22 namespace carl {
23 namespace logging {
24 
25 #if defined LOGGING
26  #define CARL_LOGGING_ENABLED
27  #define CARL_LOG_FATAL(channel, msg) __CARL_LOG_FATAL(channel, msg)
28  #define CARL_LOG_ERROR(channel, msg) __CARL_LOG_ERROR(channel, msg)
29  #define CARL_LOG_WARN(channel, msg) __CARL_LOG_WARN(channel, msg)
30  #define CARL_LOG_INFO(channel, msg) __CARL_LOG_INFO(channel, msg)
31  #define CARL_LOG_DEBUG(channel, msg) __CARL_LOG_DEBUG(channel, msg)
32  #define CARL_LOG_TRACE(channel, msg) __CARL_LOG_TRACE(channel, msg)
33 
34  #define CARL_LOG_FUNC(channel, args) __CARL_LOG_FUNC(channel, args)
35  #define CARL_LOG_ASSERT(channel, condition, msg) __CARL_LOG_ASSERT(channel, condition, msg)
36  #define CARL_LOG_NOTIMPLEMENTED() __CARL_LOG_ERROR("", "Not implemented method-stub called.")
37  #define CARL_LOG_INEFFICIENT() __CARL_LOG_WARN("", "Inefficient method called.")
38 #else
39  #define CARL_LOG_FATAL(channel, msg) std::cerr << (channel) << ": " << msg << std::endl;
40  #define CARL_LOG_ERROR(channel, msg) std::cerr << (channel) << ": " << msg << std::endl;
41  #define CARL_LOG_WARN(channel, msg)
42  #define CARL_LOG_INFO(channel, msg)
43  #define CARL_LOG_DEBUG(channel, msg)
44  #define CARL_LOG_TRACE(channel, msg)
45 
46  #define CARL_LOG_FUNC(channel, args)
47  #define CARL_LOG_ASSERT(channel, condition, msg) assert(condition)
48  #define CARL_LOG_NOTIMPLEMENTED()
49  #define CARL_LOG_INEFFICIENT()
50 #endif
51 
52 #ifdef LOGGING_DISABLE_INEFFICIENT
53  #undef CARL_LOG_INEFFICIENT
54  #define CARL_LOG_INEFFICIENT()
55  #undef CARL_LOG_NOTIMPLEMENTED
56  #define CARL_LOG_NOTIMPLEMENTED()
57 #endif
58 
59 void setInitialLogLevel();
60 
61 inline void configureLogging() {
62 #ifdef CARL_LOGGING_ENABLED
63  #if defined NDEBUG
64  std::cerr << "CArL: You are running in release mode with logging enabled. Are you sure, that this is what you want?" << std::endl;
65  #endif
67 #endif
68 }
69 
70 }
71 }
carl is the main namespace for the library.
void setInitialLogLevel()
Definition: carl-logging.cpp:8
void configureLogging()
Definition: carl-logging.h:61