ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
log.h
Go to the documentation of this file.
1 
4 #ifndef ILANG_UTIL_LOG_H__
5 #define ILANG_UTIL_LOG_H__
6 
7 #include <set>
8 #include <string>
9 
10 #include <glog/logging.h>
11 
12 namespace ilang {
13 
14 // Only in Debug mode (Ignored in Release mode)
15 /******************************************************************************/
17 #define ILA_DLOG(tag) DLOG_IF(INFO, DebugLog::Find(tag)) << "[" << tag << "] "
18 
20 #define ILA_INFO DLOG(INFO)
21 #define ILA_WARN DLOG(WARNING)
23 #define ILA_ERROR DLOG(ERROR)
25 #define ILA_INFO_IF(b) DLOG_IF(INFO, b)
27 #define ILA_WARN_IF(b) DLOG_IF(WARNING, b)
29 #define ILA_ERROR_IF(b) DLOG_IF(ERROR, b)
31 
33 #define ILA_ASSERT(b) DLOG_IF(FATAL, !(b))
34 
35 // Both in Debug and Release mode
36 // (Use only if high-assurance & non-performance critical)
37 /******************************************************************************/
39 #define ILA_CHECK(b) CHECK(b)
40 #define ILA_CHECK_EQ(a, b) CHECK_EQ(a, b)
42 #define ILA_CHECK_NE(a, b) CHECK_NE(a, b)
44 #define ILA_CHECK_STREQ(a, b) CHECK_STREQ(a, b)
46 #define ILA_NOT_NULL(ptr) CHECK_NOTNULL(ptr)
48 //#define ILA_NOT_NULL(ptr) CHECK(ptr)
49 
56 void SetLogLevel(const int& lvl);
57 
61 void SetLogPath(const std::string& path);
62 
65 void SetToStdErr(const int& to_err);
66 
67 // Wrapper for debug tag log system.
68 /******************************************************************************/
70 class LogInitter {
71 public:
73  LogInitter();
74 }; // class LogInitter
75 
77 class DebugLog {
78 public:
80  static void Enable(const std::string& tag);
81 
83  static void Disable(const std::string& tag);
84 
86  static void Clear();
87 
89  static bool Find(const std::string& tag);
90 
91 private:
93  static std::set<std::string> debug_tags_;
94 
96  static LogInitter init_;
97 
98 }; // class DebugLog
99 
100 } // namespace ilang
101 
102 #endif // ILANG_UTIL_LOG_H__
void SetToStdErr(const int &to_err)
Pipe log to stderr. Log messages to stderr instead of logfiles, if set to 1.
static void Disable(const std::string &tag)
Remove a debug tag.
A one-time class for initializing GLog.
Definition: log.h:70
static bool Find(const std::string &tag)
Find if the tag is enabled.
The wrapper for enabling and disabling debug tags.
Definition: log.h:77
static void Clear()
Clear all tags.
LogInitter()
Constructor to initialize GLog.
void SetLogPath(const std::string &path)
Set the path for log file. If specified, logfiles are written into this directory instead of the defa...
void SetLogLevel(const int &lvl)
Set the minimun log level. Log messages at or above this level will be logged. (Default: 0) ...
static void Enable(const std::string &tag)
Add a debug tag.