1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
Logger.cpp
Go to the documentation of this file.
1
// //////////////////////////////////////////////////////////////////////
2
// Import section
3
// //////////////////////////////////////////////////////////////////////
4
// STL
5
#include <iostream>
6
// StdAir Logger
7
#include <
stdair/stdair_exceptions.hpp
>
8
#include <
stdair/service/Logger.hpp
>
9
10
namespace
stdair
{
11
12
// //////////////////////////////////////////////////////////////////////
13
Logger::Logger()
14
: _level (
LOG
::
DEBUG
), _logStream (&std::cout),
15
_hasBeenInitialised (false) {
16
}
17
18
// //////////////////////////////////////////////////////////////////////
19
Logger::Logger (
const
Logger&)
20
: _level (LOG::
DEBUG
), _logStream (&std::cout),
21
_hasBeenInitialised (false) {
22
assert (
false
);
23
}
24
25
// //////////////////////////////////////////////////////////////////////
26
Logger::~Logger() {
27
// std::cout << "In Logger destructor" << std::endl;
28
}
29
30
// //////////////////////////////////////////////////////////////////////
31
void
Logger::init (
const
BasLogParams& iLogParams) {
32
33
//
34
Logger& lInstance = instance();
35
const
bool
hasBeenInitialised = lInstance.getStatus();
36
if
(hasBeenInitialised ==
true
37
&& iLogParams.getForcedInitialisationFlag() ==
false
) {
38
STDAIR_LOG_ERROR
(
"Error: the log stream has already been initialised"
);
39
assert (
false
);
40
}
41
42
lInstance.setLevel (iLogParams._logLevel);
43
lInstance.setStream (iLogParams._logStream);
44
lInstance.setStatus (
true
);
45
}
46
47
// //////////////////////////////////////////////////////////////////////
48
Logger&
Logger::instance
() {
49
static
Logger
_instance
;
50
return
_instance
;
51
}
52
53
// //////////////////////////////////////////////////////////////////////
54
BasLogParams
Logger::getLogParams() {
55
std::ostream* oStream_ptr = instance()._logStream;
56
assert (oStream_ptr != NULL);
57
return
BasLogParams
(instance()._level, *oStream_ptr);
58
}
59
60
// //////////////////////////////////////////////////////////////////////
61
void
Logger::clean() {
62
Logger& lInstance = instance();
63
lInstance.setStatus (
false
);
64
}
65
66
}
Logger.hpp
STDAIR_LOG_ERROR
#define STDAIR_LOG_ERROR(iToBeLogged)
Definition
Logger.hpp:23
stdair_exceptions.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::_instance
FacBom< BOM > * FacBom< BOM >::_instance
Definition
FacBom.hpp:81
stdair::LOG
Definition
stdair_log.hpp:17
stdair::LOG::DEBUG
@ DEBUG
Definition
stdair_log.hpp:23
stdair::BasLogParams
Structure holding parameters for logging.
Definition
BasLogParams.hpp:19
stdair::Logger::instance
static Logger & instance()
Definition
Logger.cpp:48
Generated for StdAir by
1.17.0