μHAL (v2.7.9)
Part of the IPbus software repository
LogLevels.cpp
Go to the documentation of this file.
1 
2 #include "uhal/log/LogLevels.hpp"
3 
4 
7 
8 
9 namespace 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 
uhal::NoticeLevel
Helper struct representing the Notice log level to allow us to specialize functions according to thei...
Definition: LogLevels.hpp:130
uhal::usec
@ usec
microseconds past the second formatted as exactly six digits e.g.
Definition: log_inserters.time.hpp:65
uhal::WarningLevel::WarningLevel
WarningLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=WarningLevel::colour_head, Base::fPtr aTailFunction=WarningLevel::colour_tail)
Definition: LogLevels.cpp:64
uhal::ThisThreadID
Definition: log_inserters.threadID.hpp:44
uhal::InfoLevel::InfoLevel
InfoLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=InfoLevel::colour_head, Base::fPtr aTailFunction=InfoLevel::colour_tail)
Definition: LogLevels.cpp:100
uhal::ErrorLevel::colour_head
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:48
uhal::yr
@ yr
year formatted as two digits e.g.
Definition: log_inserters.time.hpp:58
log_inserters.threadID.hpp
uhal::day
@ day
day of the month formatted as two digits e.g.
Definition: log_inserters.time.hpp:61
uhal::hr
@ hr
hour of the day formatted as two digits, 24-hour clock e.g.
Definition: log_inserters.time.hpp:62
uhal::InfoLevel::colour_tail
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:110
uhal::InfoLevel::colour_head
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:102
uhal::FatalLevel
Helper struct representing the Fatal log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:85
uhal::DebugLevel::colour_tail
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:128
uhal::insert
void insert(std::ostream &aStr, const U &aU)
Definition: LogLevels.hpp:25
uhal::min
@ min
minutes past the hour formatted as two digits e.g.
Definition: log_inserters.time.hpp:63
uhal::WarningLevel::colour_tail
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:74
uhal::FatalLevel::FatalLevel
FatalLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=FatalLevel::colour_head, Base::fPtr aTailFunction=FatalLevel::colour_tail)
Definition: LogLevels.cpp:28
uhal
Definition: HttpResponseGrammar.hpp:49
uhal::DebugLevel::colour_head
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:120
uhal::NoticeLevel::NoticeLevel
NoticeLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=NoticeLevel::colour_head, Base::fPtr aTailFunction=NoticeLevel::colour_tail)
Definition: LogLevels.cpp:82
uhal::ErrorLevel::colour_tail
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:56
uhal::Info
InfoLevel Info
Definition: LogLevels.cpp:115
uhal::NoticeLevel::colour_tail
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:92
uhal::ErrorLevel::ErrorLevel
ErrorLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=ErrorLevel::colour_head, Base::fPtr aTailFunction=ErrorLevel::colour_tail)
Definition: LogLevels.cpp:46
uhal::Warning
WarningLevel Warning
Definition: LogLevels.cpp:79
uhal::Error
ErrorLevel Error
Definition: LogLevels.cpp:61
uhal::FatalLevel::colour_tail
static void colour_tail(std::ostream &aStr)
Definition: LogLevels.cpp:38
uhal::sec
@ sec
seconds past the minute formatted as two digits e.g.
Definition: log_inserters.time.hpp:64
uhal::Now
timeval Now()
A helper function to return the current time.
Definition: log_inserters.time.cpp:155
uhal::WarningLevel
Helper struct representing the Warning log level to allow us to specialize functions according to the...
Definition: LogLevels.hpp:116
uhal::InfoLevel
Helper struct representing the Info log level to allow us to specialize functions according to their ...
Definition: LogLevels.hpp:145
uhal::WarningLevel::colour_head
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:66
uhal::Debug
DebugLevel Debug
Definition: LogLevels.cpp:133
uhal::mth
@ mth
month formatted as two digits e.g.
Definition: log_inserters.time.hpp:60
uhal::FatalLevel::colour_head
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:30
uhal::Time
_Time< DefaultTimeFmt > Time(const timeval &aTime)
Helper function which wrap the template uglyness in a pretty package.
Definition: log_inserters.time.hxx:53
uhal::Notice
NoticeLevel Notice
Definition: LogLevels.cpp:97
log_inserters.time.hpp
uhal::BaseLogLevel< FatalLevel >
uhal::DebugLevel::DebugLevel
DebugLevel(std::ostream &aStr=std::cout, Base::fPtr aHeadFunction=DebugLevel::colour_head, Base::fPtr aTailFunction=DebugLevel::colour_tail)
Definition: LogLevels.cpp:118
uhal::DebugLevel
Helper struct representing the Debug log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:159
LogLevels.hpp
uhal::Fatal
FatalLevel Fatal
Definition: LogLevels.cpp:43
uhal::NoticeLevel::colour_head
static void colour_head(std::ostream &aStr)
Definition: LogLevels.cpp:84
uhal::ErrorLevel
Helper struct representing the Error log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:100