Functions
mfexample.cc File Reference
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include <string>
#include <thread>

Go to the source code of this file.

Functions

void anotherLogger ()
 
int main ()
 

Function Documentation

void anotherLogger ( )

Definition at line 12 of file mfexample.cc.

13 {
14  mf::SetModuleName("anotherLogger"s);
15  mf::LogWarning("cat1|cat2"s)
16  << "A WARNING message from the anotherLogger thread.";
17  mf::LogDebug("cat1"s) << "The debug message in the anotherLogger thread";
18  return;
19 }
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void SetModuleName(string const &val)
static QCString * s
Definition: config.cpp:1042
int main ( void  )

Definition at line 22 of file mfexample.cc.

23 {
24  string const psString{" statistics: [\"stats\"]"
25  " destinations: {"
26  " console: { type: \"cout\" threshold: \"DEBUG\" }"
27  " file: {"
28  " type: \"file\" threshold: \"DEBUG\""
29  " filename: \"mylog\""
30  " append: false"
31  " }"
32  " }"};
33 
35  // Set application name (use process name by default)
36  mf::SetApplicationName("MF_Example"s);
37  // Set module name for the main thread
38  mf::SetModuleName("MF_main"s);
39  mf::SetIteration("pre-event"s);
40 
41  // Start up another logger in a separate thread
42  thread loggerThread(anotherLogger);
43  // Issue messages with different severity levels
44  mf::LogError("cat1|cat2"s) << "This is an ERROR message.";
45  mf::LogWarning("cat3"s) << "Followed by a WARNING message.";
46  // Switch iteration
47  mf::SetIteration("pro-event"s);
48  // Logs
49  mf::LogError("cat2"s) << "Error information.";
50  mf::LogWarning("cat3"s) << "Warning information.";
51  mf::LogInfo("cat4"s) << "Info information.";
52  mf::LogDebug("cat5"s) << "DEBUG information.";
53  // Join with logger thread
54  loggerThread.join();
55  // Log statistics
57  return 0;
58 }
void SetIteration(string const &val)
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
void LogStatistics()
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void SetModuleName(string const &val)
void SetApplicationName(string const &applicationName)
void anotherLogger()
Definition: mfexample.cc:12
static QCString * s
Definition: config.cpp:1042