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 
32 void LogStream::enableHeader() { write_header = true; }
33 void LogStream::disableHeader() { write_header = false; }
34 void LogStream::enableTimeStamp() { write_stamp = true; }
35 void LogStream::disableTimeStamp() { write_stamp = false; }
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 
40 bool LogStream::isEnabled() {
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 
57 LogStream& LogStream::log(int mode) {
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 
ecl::LogStream::write_stamp
bool write_stamp
Definition: log_stream.hpp:226
ecl::LogStream::timestamp
TimeStamp timestamp
Definition: log_stream.hpp:228
ecl::LogStream::isModeEnabled
bool isModeEnabled(int mode)
Check to see if a particular mode is enabled.
Definition: log_stream.cpp:52
ecl::LogStream::enableMode
void enableMode(int mode, const std::string header="")
Enable the given mode and associate the specified header.
Definition: log_stream.cpp:41
ecl::LogStream::disableHeader
void disableHeader()
Disables header information.
Definition: log_stream.cpp:37
ecl::LogStream::write_header
bool write_header
Definition: log_stream.hpp:225
ecl::LogStream::isEnabled
bool isEnabled()
Check to see if any modes are enabled.
Definition: log_stream.cpp:44
ecl::LogStream::log
LogStream & log(int mode)
Log streaming function.
Definition: log_stream.cpp:61
ecl::LogStream::enableHeader
void enableHeader()
Enable header information.
Definition: log_stream.cpp:36
ecl::LogStream::disableMode
void disableMode(int mode)
Disable the given log mode.
Definition: log_stream.cpp:42
ecl::LogStream::modes
std::map< int, std::string > modes
Definition: log_stream.hpp:227
ecl::LogStream::disableTimeStamp
void disableTimeStamp()
Disable time stamps.
Definition: log_stream.cpp:39
ecl
ecl::LogStream::enableTimeStamp
void enableTimeStamp()
Enable time stamps.
Definition: log_stream.cpp:38


ecl_streams
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:48