MessageLoggerConfig.cc
Go to the documentation of this file.
1 #include <utl/MessageLoggerConfig.h>
2 
3 #include <utl/MessageLogger.h>
4 #include <utl/ConfigUtils.h>
5 
6 
7 namespace utl {
8 
10  fTheLogger(l)
11  {
12  Configure(config);
13  }
14 
15 
17  fTheLogger(l)
18  { }
19 
20 
22  fOwnLogger(new MessageLogger(fOutput, fLevel)),
23  fTheLogger(*fOwnLogger)
24  {
25  Configure(config);
26  }
27 
28 
30  fOwnLogger(new MessageLogger(fOutput, fLevel)),
31  fTheLogger(*fOwnLogger)
32  { }
33 
34 
35  void
37  {
38  LoadConfig(config, "verbosityLevel", fLevel, 1);
39  LoadConfig(config, "outputFilename", fOutputFilename, "");
40  LoadConfig(config, "nPrecDigits", fNPrecDigits, 2);
41  LoadConfig(config, "flushPeriod", fFlushPeriod, 0);
42  if (fOutputFilename.empty())
43  fOutput.setstate(std::ios_base::badbit); // Set as bad so as not to be used in the messageLoger.
44  else
45  fOutput.open(fOutputFilename.c_str());
46  }
47 
48 
49  void
51  {
52  LoadConfiguration(config);
54  }
55 
56 
57  void
59  {
63  }
64 
65 }
void SetLevel(unsigned int l)
Set a new level.
void ApplyConfiguration()
Apply already loaded configuration.
void LoadConfiguration(const Branch &config)
std::ofstream fOutput
Output message sink.
Class representing a document branch.
Definition: Branch.h:107
unsigned int fFlushPeriod
The period.
void SetNPrecDigits(unsigned int n)
Set a new number of digits.
void SetFlushPeriod(unsigned int p)
Set a new period.
void Configure(const Branch &config)
unsigned int fNPrecDigits
Precission digits.
void LoadConfig(const utl::Branch &b, const std::string &tag, T1 &var, const T2 &defaultValue)
Helper method to load a particular configuration parameter.
Definition: ConfigUtils.h:35
std::string fOutputFilename
Output log filename (if empty, then cout).
Handle diagnosis messages output.
Definition: MessageLogger.h:38
MessageLogger & fTheLogger
The logger to configure.
MessageLoggerConfig()
Create a configurator without any configuration yet.

, generated on Tue Sep 26 2023.