BubbleProfiler
0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
src
logging_manager.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of BubbleProfiler.
3
*
4
* BubbleProfiler is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* BubbleProfiler is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with BubbleProfiler. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#include "
logging_manager.hpp
"
19
#include "
error.hpp
"
20
21
#include <iostream>
22
23
namespace
BubbleProfiler
{
24
25
namespace
logging {
26
27
Logging_manager
&
Logging_manager::get_manager
()
28
{
29
static
Logging_manager
instance;
30
31
return
instance;
32
}
33
34
bool
Logging_manager::above_min_level
(
Log_level
level)
const
35
{
36
bool
result =
true
;
37
switch
(
min_level
) {
38
case
Log_level::Trace
: {
39
break
;
40
}
41
case
Log_level::Debug
: {
42
if
(level ==
Log_level::Trace
) {
43
result =
false
;
44
}
45
break
;
46
}
47
case
Log_level::Info
: {
48
if
(level ==
Log_level::Trace
||
49
level ==
Log_level::Debug
) {
50
result =
false
;
51
}
52
break
;
53
}
54
case
Log_level::Warning
: {
55
if
(level ==
Log_level::Trace
||
56
level ==
Log_level::Debug
||
57
level ==
Log_level::Info
) {
58
result =
false
;
59
}
60
break
;
61
}
62
case
Log_level::Error
: {
63
if
(level !=
Log_level::Error
&&
64
level !=
Log_level::Fatal
) {
65
result =
false
;
66
}
67
break
;
68
}
69
case
Log_level::Fatal
: {
70
if
(level !=
Log_level::Fatal
) {
71
result =
false
;
72
}
73
break
;
74
}
75
default
: {
76
throw
Error
(
"unrecognized log level"
);
77
}
78
}
79
80
return
result;
81
}
82
83
void
Logging_manager::log
(
const
Log_message
& message)
84
{
85
if
(
logging_enabled
&&
above_min_level
(message.
get_log_level
())) {
86
std::cerr << message.
get_log_entry
();
87
}
88
}
89
90
}
// namespace logging
91
92
}
// namespace BubbleProfiler
logging_manager.hpp
BubbleProfiler::logging::Log_message::get_log_level
virtual Log_level get_log_level() const =0
BubbleProfiler::logging::Logging_manager
Definition:
logging_manager.hpp:27
BubbleProfiler::logging::Logging_manager::min_level
Log_level min_level
Definition:
logging_manager.hpp:47
BubbleProfiler::logging::Log_level::Trace
BubbleProfiler::logging::Logging_manager::get_manager
static Logging_manager & get_manager()
Definition:
logging_manager.cpp:27
BubbleProfiler::logging::Logging_manager::above_min_level
bool above_min_level(Log_level) const
Definition:
logging_manager.cpp:34
BubbleProfiler::logging::Log_level::Warning
BubbleProfiler::logging::Log_level::Fatal
BubbleProfiler::logging::Log_message
Definition:
log_message.hpp:32
error.hpp
BubbleProfiler::logging::Log_level
Log_level
Definition:
log_message.hpp:28
BubbleProfiler::logging::Log_level::Info
BubbleProfiler::logging::Log_level::Debug
BubbleProfiler::logging::Logging_manager::log
void log(const Log_message &message)
Definition:
logging_manager.cpp:83
BubbleProfiler::logging::Log_level::Error
BubbleProfiler::logging::Logging_manager::logging_enabled
bool logging_enabled
Definition:
logging_manager.hpp:46
BubbleProfiler
Definition:
action.hpp:33
BubbleProfiler::logging::Log_message::get_log_entry
virtual std::string get_log_entry() const =0
Generated on Wed Jan 2 2019 13:08:19 for BubbleProfiler by
1.8.11