Typedefs | Functions
WireCell::Log Namespace Reference

Typedefs

typedef std::shared_ptr< spdlog::loggerlogptr_t
 
typedef std::shared_ptr< spdlog::sinks::sinksinkptr_t
 

Functions

void add_sink (sinkptr_t sink, std::string level="")
 
void add_file (std::string filename, std::string level="")
 
void add_stdout (bool color=true, std::string level="")
 
void add_stderr (bool color=true, std::string level="")
 
logptr_t logger (std::string name)
 
void set_level (std::string level, std::string which="")
 
void set_pattern (std::string pattern, std::string which="")
 

Typedef Documentation

typedef std::shared_ptr<spdlog::logger> WireCell::Log::logptr_t

Definition at line 24 of file Logging.h.

Definition at line 25 of file Logging.h.

Function Documentation

void WireCell::Log::add_file ( std::string  filename,
std::string  level = "" 
)

Definition at line 42 of file Logging.cxx.

43 {
44  auto s = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename);
46 }
string filename
Definition: train.py:213
void add_sink(sinkptr_t sink, std::string level="")
Definition: Logging.cxx:35
static QCString * s
Definition: config.cpp:1042
void WireCell::Log::add_sink ( Log::sinkptr_t  sink,
std::string  level = "" 
)

Definition at line 35 of file Logging.cxx.

36 {
37  if (!level.empty()) {
38  sink->set_level(spdlog::level::from_str(level));
39  }
40  wct_base_logger()->sinks().push_back(sink);
41 }
spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
Definition: common.h:142
static Log::logptr_t wct_base_logger()
Definition: Logging.cxx:13
void WireCell::Log::add_stderr ( bool  color = true,
std::string  level = "" 
)

Definition at line 59 of file Logging.cxx.

60 {
61  if (color) {
62  auto s = std::make_shared<spdlog::sinks::stderr_color_sink_mt>();
64  }
65  else {
66  auto s = std::make_shared<spdlog::sinks::stderr_sink_mt>();
68  }
69 }
color
Definition: color.h:50
void add_sink(sinkptr_t sink, std::string level="")
Definition: Logging.cxx:35
static QCString * s
Definition: config.cpp:1042
void WireCell::Log::add_stdout ( bool  color = true,
std::string  level = "" 
)

Definition at line 48 of file Logging.cxx.

49 {
50  if (color) {
51  auto s = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
53  }
54  else {
55  auto s = std::make_shared<spdlog::sinks::stdout_sink_mt>();
57  }
58 }
color
Definition: color.h:50
void add_sink(sinkptr_t sink, std::string level="")
Definition: Logging.cxx:35
static QCString * s
Definition: config.cpp:1042
Log::logptr_t WireCell::Log::logger ( std::string  name)

Definition at line 71 of file Logging.cxx.

72 {
73  wct_base_logger(); // make sure base logger is installed.
74  auto l = spdlog::get(name);
75  if (!l) {
76  auto& sinks = wct_base_logger()->sinks();
77  l = std::make_shared<spdlog::logger>(name, sinks.begin(), sinks.end());
78 
79  // peak under the hood of spdlog. We want shared loggers to
80  // get configured with the default level.
82  if (!spdlog::get(name)) {
84  }
85  }
86 
87  return l;
88 }
static QCString name
Definition: declinfo.cpp:673
std::shared_ptr< logger > get(const std::string &name)
Definition: spdlog.h:53
static registry & instance()
Definition: registry.h:228
static QStrList * l
Definition: config.cpp:1044
static Log::logptr_t wct_base_logger()
Definition: Logging.cxx:13
void initialize_logger(std::shared_ptr< logger > new_logger)
Definition: registry.h:48
void register_logger(std::shared_ptr< logger > logger)
Definition: spdlog.h:97
void WireCell::Log::set_level ( std::string  level,
std::string  which = "" 
)

Definition at line 90 of file Logging.cxx.

91 {
92  auto lvl = spdlog::level::from_str(level);
93 
94  if (which.empty()) {
95  spdlog::set_level(lvl);
96  return;
97  }
98  logger(which)->set_level(lvl);
99 }
spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
Definition: common.h:142
logptr_t logger(std::string name)
Definition: Logging.cxx:71
void set_level(level::level_enum log_level)
Definition: spdlog.h:72
void WireCell::Log::set_pattern ( std::string  pattern,
std::string  which = "" 
)

Definition at line 100 of file Logging.cxx.

101 {
102  if (which.empty()) {
104  return;
105  }
106  logger(which)->set_pattern(pattern);
107 }
logptr_t logger(std::string name)
Definition: Logging.cxx:71
void set_pattern(std::string pattern, pattern_time_type time_type=pattern_time_type::local)
Definition: spdlog.h:66
std::string pattern
Definition: regex_t.cc:33