log_stream.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <utility>
14 #include "../../include/ecl/streams/log_stream.hpp"
15 
16 /*****************************************************************************
17 ** Namespaces
18 *****************************************************************************/
19 
20 namespace ecl {
21 
22 /*****************************************************************************
23 ** Using
24 *****************************************************************************/
25 
26 using std::string;
27 
28 /*****************************************************************************
29 ** Implementation [LogStream]
30 *****************************************************************************/
31 
36 
37 void LogStream::enableMode(int mode, std::string header) { modes.insert( std::make_pair(mode,header) ); }
38 void LogStream::disableMode(int mode) { modes.erase(mode); }
39 
41  if ( modes.size() > 0 ) {
42  return true;
43  } else {
44  return false;
45  }
46 }
47 
48 bool LogStream::isModeEnabled(int mode) {
49 
50  if( modes.count(mode) > 0 ) {
51  return true;
52  } else {
53  return false;
54  }
55 }
56 
58  if ( write_stamp ) {
59  (*this) << timestamp.stamp() << " ";
60  }
61  if ( write_header ) {
62  (*this) << "[" << modes[mode] << "] ";
63  }
64  if ( write_stamp || write_header ) {
65  (*this) << ": ";
66  }
67  return (*this);
68 }
69 
70 } // namespace ecl
71 
LogStream & log(int mode)
Log streaming function.
Definition: log_stream.cpp:57
void enableMode(int mode, const std::string header="")
Enable the given mode and associate the specified header.
Definition: log_stream.cpp:37
std::map< int, std::string > modes
Definition: log_stream.hpp:221
void disableMode(int mode)
Disable the given log mode.
Definition: log_stream.cpp:38
A customised textstream for fast, multithreaded logging to file.
Definition: log_stream.hpp:110
void disableTimeStamp()
Disable time stamps.
Definition: log_stream.cpp:35
void enableHeader()
Enable header information.
Definition: log_stream.cpp:32
void enableTimeStamp()
Enable time stamps.
Definition: log_stream.cpp:34
bool isEnabled()
Check to see if any modes are enabled.
Definition: log_stream.cpp:40
void disableHeader()
Disables header information.
Definition: log_stream.cpp:33
bool isModeEnabled(int mode)
Check to see if a particular mode is enabled.
Definition: log_stream.cpp:48
TimeStamp timestamp
Definition: log_stream.hpp:222


ecl_streams
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 21:59:07