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