μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LogLevels.cpp
Go to the documentation of this file.
1
3
4
7
8
9namespace uhal
10{
11
12 void insert ( std::ostream& aStr , const uint32_t& aUint )
13 {
14 aStr << aUint;
15 }
16
17 void insert ( std::ostream& aStr , const int32_t& aInt )
18 {
19 aStr << aInt;
20 }
21
22 void insert ( std::ostream& aStr , const bool& aBool )
23 {
24 aStr << aBool;
25 }
26
27
28 FatalLevel::FatalLevel ( std::ostream& aStr , Base::fPtr aHeadFunction, Base::fPtr aTailFunction ) : Base ( aStr , aHeadFunction , aTailFunction ) {}
29
30 void FatalLevel::colour_head ( std::ostream& aStr )
31 {
32 aStr << "\033[0;31m" //standard red
33 << Time< day,'-',mth,'-',yr,' ',hr,':',min,':',sec,'.',usec > ( Now() )
34 << " [" << ThisThreadID() << "]"
35 << " FATAL - ";
36 }
37
38 void FatalLevel::colour_tail ( std::ostream& aStr )
39 {
40 aStr << "\033[0m" << std::endl;
41 }
42
44
45
46 ErrorLevel::ErrorLevel ( std::ostream& aStr, Base::fPtr aHeadFunction, Base::fPtr aTailFunction ) : Base ( aStr , aHeadFunction , aTailFunction ) {}
47
48 void ErrorLevel::colour_head ( std::ostream& aStr )
49 {
50 aStr << "\033[0;31m" //standard red
51 << Time< day,'-',mth,'-',yr,' ',hr,':',min,':',sec,'.',usec > ( Now() )
52 << " [" << ThisThreadID() << "]"
53 << " ERROR - ";
54 }
55
56 void ErrorLevel::colour_tail ( std::ostream& aStr )
57 {
58 aStr << "\033[0m" << std::endl;
59 }
60
62
63
64 WarningLevel::WarningLevel ( std::ostream& aStr, Base::fPtr aHeadFunction, Base::fPtr aTailFunction ) : Base ( aStr , aHeadFunction , aTailFunction ) {}
65
66 void WarningLevel::colour_head ( std::ostream& aStr )
67 {
68 aStr << "\033[0;33m" //standard yellow
69 << Time< day,'-',mth,'-',yr,' ',hr,':',min,':',sec,'.',usec > ( Now() )
70 << " [" << ThisThreadID() << "]"
71 << " WARNING - ";
72 }
73
74 void WarningLevel::colour_tail ( std::ostream& aStr )
75 {
76 aStr << "\033[0m" << std::endl;
77 }
78
80
81
82 NoticeLevel::NoticeLevel ( std::ostream& aStr, Base::fPtr aHeadFunction, Base::fPtr aTailFunction ) : Base ( aStr , aHeadFunction , aTailFunction ) {}
83
84 void NoticeLevel::colour_head ( std::ostream& aStr )
85 {
86 aStr << "\033[0;32m" //standard green
87 << Time< day,'-',mth,'-',yr,' ',hr,':',min,':',sec,'.',usec > ( Now() )
88 << " [" << ThisThreadID() << "]"
89 << " NOTICE - ";
90 }
91
92 void NoticeLevel::colour_tail ( std::ostream& aStr )
93 {
94 aStr << "\033[0m" << std::endl;
95 }
96
98
99
100 InfoLevel::InfoLevel ( std::ostream& aStr, Base::fPtr aHeadFunction, Base::fPtr aTailFunction ) : Base ( aStr , aHeadFunction , aTailFunction ) {}
101
102 void InfoLevel::colour_head ( std::ostream& aStr )
103 {
104 aStr << "\033[0;36m" //standard cyan
105 << Time< day,'-',mth,'-',yr,' ',hr,':',min,':',sec,'.',usec > ( Now() )
106 << " [" << ThisThreadID() << "]"
107 << " INFO - ";
108 }
109
110 void InfoLevel::colour_tail ( std::ostream& aStr )
111 {
112 aStr << "\033[0m" << std::endl;
113 }
114
116
117
118 DebugLevel::DebugLevel ( std::ostream& aStr, Base::fPtr aHeadFunction, Base::fPtr aTailFunction ) : Base ( aStr , aHeadFunction , aTailFunction ) {}
119
120 void DebugLevel::colour_head ( std::ostream& aStr )
121 {
122 aStr << "\033[0;34m" //standard blue
123 << Time< day,'-',mth,'-',yr,' ',hr,':',min,':',sec,'.',usec > ( Now() )
124 << " [" << ThisThreadID() << "]"
125 << " DEBUG - ";
126 }
127
128 void DebugLevel::colour_tail ( std::ostream& aStr )
129 {
130 aStr << "\033[0m" << std::endl;
131 }
132
134
135}
136
137
138
139
Helper struct representing the Debug log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:159
DebugLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=DebugLevel::colour_head, Base::fPtr aTailFunction=DebugLevel::colour_tail)
Definition: LogLevels.cpp:118
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:128
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:120
Helper struct representing the Error log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:100
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:56
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:48
ErrorLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=ErrorLevel::colour_head, Base::fPtr aTailFunction=ErrorLevel::colour_tail)
Definition: LogLevels.cpp:46
Helper struct representing the Fatal log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:85
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:30
FatalLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=FatalLevel::colour_head, Base::fPtr aTailFunction=FatalLevel::colour_tail)
Definition: LogLevels.cpp:28
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:38
Helper struct representing the Info log level to allow us to specialize functions according to their ...
Definition: LogLevels.hpp:145
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:110
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:102
InfoLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=InfoLevel::colour_head, Base::fPtr aTailFunction=InfoLevel::colour_tail)
Definition: LogLevels.cpp:100
Helper struct representing the Notice log level to allow us to specialize functions according to thei...
Definition: LogLevels.hpp:130
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:84
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:92
NoticeLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=NoticeLevel::colour_head, Base::fPtr aTailFunction=NoticeLevel::colour_tail)
Definition: LogLevels.cpp:82
Helper struct representing the Warning log level to allow us to specialize functions according to the...
Definition: LogLevels.hpp:116
WarningLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=WarningLevel::colour_head, Base::fPtr aTailFunction=WarningLevel::colour_tail)
Definition: LogLevels.cpp:64
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:66
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:74
timeval Now()
A helper function to return the current time.
_Time< DefaultTimeFmt > Time(const timeval &aTime)
Helper function which wrap the template uglyness in a pretty package.
DebugLevel Debug
Definition: LogLevels.cpp:133
void insert(std::ostream &aStr, const U &aU)
Definition: LogLevels.hpp:25
ErrorLevel Error
Definition: LogLevels.cpp:61
@ day
day of the month formatted as two digits e.g.
@ sec
seconds past the minute formatted as two digits e.g.
@ yr
year formatted as two digits e.g.
@ mth
month formatted as two digits e.g.
@ usec
microseconds past the second formatted as exactly six digits e.g.
@ hr
hour of the day formatted as two digits, 24-hour clock e.g.
@ min
minutes past the hour formatted as two digits e.g.
FatalLevel Fatal
Definition: LogLevels.cpp:43
WarningLevel Warning
Definition: LogLevels.cpp:79
InfoLevel Info
Definition: LogLevels.cpp:115
NoticeLevel Notice
Definition: LogLevels.cpp:97