scc  2024.06
SystemC components library
report.h
1 /*******************************************************************************
2  * Copyright 2016-2022 MINRES Technologies GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************/
16 
17 #ifndef _SCP_REPORT_H_
18 #define _SCP_REPORT_H_
19 
20 #include <scc/report.h>
21 
24 #define SCP_LOG_LEVEL_PARAM_NAME "log_level"
25 
26 namespace scp {
27 using log = ::scc::log;
28 using LogConfig = ::scc::LogConfig;
29 void init_logging(log level = log::WARNING, unsigned type_field_width = 24, bool print_time = false) {
30  scc::init_logging(level, type_field_width, print_time);
31 }
32 void reinit_logging(log level) { scc::reinit_logging(level); }
33 void init_logging(const LogConfig& log_config) { scc::init_logging(log_config); }
34 void set_logging_level(log level) { scc::set_logging_level(level); }
36 void set_cycle_base(sc_core::sc_time period) { scc::set_cycle_base(period); }
37 inline sc_core::sc_verbosity get_log_verbosity() {
38  return static_cast<sc_core::sc_verbosity>(::sc_core::sc_report_handler::get_verbosity_level());
39 }
40 sc_core::sc_verbosity get_log_verbosity(char const* t) { return scc::get_log_verbosity(t); }
41 inline sc_core::sc_verbosity get_log_verbosity(std::string const& t) { return scc::get_log_verbosity(t.c_str()); }
42 } // namespace scp
43 
48 #define SCP_LOG(lvl, ...) ::scc::ScLogger<::sc_core::SC_INFO>(__FILE__, __LINE__, lvl / 10).type(__VA_ARGS__).get()
50 #define SCP_TRACEALL(...) \
51  if(::scc::get_log_verbosity(__VA_ARGS__) >= sc_core::SC_DEBUG) \
52  SCP_LOG(sc_core::SC_DEBUG, __VA_ARGS__)
54 #define SCP_TRACE(...) \
55  if(::scc::get_log_verbosity(__VA_ARGS__) >= sc_core::SC_FULL) \
56  SCP_LOG(sc_core::SC_FULL, __VA_ARGS__)
58 #define SCP_DEBUG(...) \
59  if(::scc::get_log_verbosity(__VA_ARGS__) >= sc_core::SC_HIGH) \
60  SCP_LOG(sc_core::SC_HIGH, __VA_ARGS__)
62 #define SCP_INFO(...) \
63  if(::scc::get_log_verbosity(__VA_ARGS__) >= sc_core::SC_MEDIUM) \
64  SCP_LOG(sc_core::SC_MEDIUM, __VA_ARGS__)
66 #define SCP_WARN(...) ::scc::ScLogger<::sc_core::SC_WARNING>(__FILE__, __LINE__, sc_core::SC_MEDIUM).type(__VA_ARGS__).get()
68 #define SCP_ERR(...) ::scc::ScLogger<::sc_core::SC_ERROR>(__FILE__, __LINE__, sc_core::SC_MEDIUM).type(__VA_ARGS__).get()
70 #define SCP_FATAL(...) ::scc::ScLogger<::sc_core::SC_FATAL>(__FILE__, __LINE__, sc_core::SC_MEDIUM).type(__VA_ARGS__).get()
71 
72 #ifdef NDEBUG
73 #define SCP_ASSERT(expr) ((void)0)
74 #else
75 #define SCP_ASSERT(expr) ((void)((expr) ? 0 : (SC_REPORT_FATAL(::sc_core::SC_ID_ASSERTION_FAILED_, #expr), 0)))
76 #endif // end of scp-report
78 #endif /* _SCP_REPORT_H_ */
void set_logging_level(log level)
sets the SystemC logging level
Definition: report.cpp:453
void init_logging(log level=log::WARNING, unsigned type_field_width=24, bool print_time=false)
initializes the SystemC logging system with a particular logging level
Definition: report.cpp:439
log get_logging_level()
get the SystemC logging level
Definition: report.cpp:461
void set_cycle_base(sc_core::sc_time period)
sets the cycle base for cycle based logging
sc_core::sc_verbosity get_log_verbosity()
get the global verbosity level
Definition: report.h:318
log
enum defining the log levels
Definition: report.h:85
the configuration class for the logging setup
Definition: report.h:162