Doxygen
Loading...
Searching...
No Matches
trace.cpp File Reference
#include "trace.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_sinks.h"
Include dependency graph for trace.cpp:

Go to the source code of this file.

Functions

void initTracing (const DString &logFile, bool timing)
void exitTracing ()

Variables

std::shared_ptr< spdlog::logger > g_tracer

Function Documentation

◆ exitTracing()

void exitTracing ( )

Definition at line 55 of file trace.cpp.

56{
57 if (g_tracer)
58 {
59 spdlog::shutdown();
60 }
61}
std::shared_ptr< spdlog::logger > g_tracer
Definition trace.cpp:23

References g_tracer.

Referenced by generateOutput(), and stopDoxygen().

◆ initTracing()

void initTracing ( const DString & logFile,
bool timing )

Definition at line 25 of file trace.cpp.

26{
27 if (!logFile.empty())
28 {
29 std::vector<spdlog::sink_ptr> sinks;
30 if (logFile=="stdout")
31 {
32 sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_mt>());
33 }
34 else if (logFile=="stderr")
35 {
36 sinks.push_back(std::make_shared<spdlog::sinks::stderr_sink_mt>());
37 }
38 else // normal file
39 {
40 sinks.push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(logFile.str(),true));
41 }
42 g_tracer = std::make_shared<spdlog::logger>("tracing", sinks.begin(),sinks.end());
43 g_tracer->set_level(spdlog::level::trace);
44 if (timing)
45 {
46 g_tracer->set_pattern("[%C-%m-%d %T.%e][%t][%s:%#](%!) %v");
47 }
48 else
49 {
50 g_tracer->set_pattern("[%s:%#](%!) %v");
51 }
52 }
53}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
const std::string & str() const
Definition dstring.h:645

References DString::empty(), g_tracer, and DString::str().

Referenced by readConfiguration().

Variable Documentation

◆ g_tracer

std::shared_ptr<spdlog::logger> g_tracer