StdAir Logo  1.00.19
C++ Standard Airline IT Object Library
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
9
10namespace 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}
#define STDAIR_LOG_ERROR(iToBeLogged)
Definition Logger.hpp:23
Handle on the StdAir library context.
FacBom< BOM > * FacBom< BOM >::_instance
Definition FacBom.hpp:81
Structure holding parameters for logging.
static Logger & instance()
Definition Logger.cpp:48