test_logging.cxx
Go to the documentation of this file.
1 #include "WireCellUtil/Testing.h"
2 #include "WireCellUtil/Logging.h"
3 
4 #include <string>
5 
6 using namespace WireCell;
7 
8 int main(int argc, char* argv[])
9 {
10  std::string fname = argv[0];
11  fname += ".log";
12 
13  auto l = Log::logger("test_logging");
15 
16  Log::add_stdout(true, "debug");
17 
18  spdlog::info("adding log file {}", fname);
19  Log::add_file(fname, "error");
20 
21  auto b = Log::logger("before");
22 
23  Log::set_level("info");
24 
25  auto a = Log::logger("after");
26 
27  Log::set_level("debug", "special");
28 
29  auto s = Log::logger("special");
30 
31  l->set_pattern("[%H:%M:%S.%03e] [%n:%L] %v");
32 
33  l->error("error test logger");
34  b->error("error other logger");
35  a->error("error other logger");
36  s->error("error other logger");
37  spdlog::error("error default logger");
38 
39  l->info("info test logger");
40  b->info("info other logger");
41  a->info("info other logger");
42  s->info("info other logger");
43  spdlog::info("info default logger");
44 
45  l->debug("debug test logger");
46  b->debug("debug other logger");
47  a->debug("debug other logger");
48  s->debug("debug other logger");
49  spdlog::debug("debug default logger");
50 
51 
52  //SPDLOG_LOGGER_DEBUG(l, "log from debug CPP macro");
53  //SPDLOG_LOGGER_TRACE(l, "log from trace CPP macro, should not see by default");
54 
55  return 0;
56 }
void info(const char *fmt, const Args &...args)
Definition: spdlog.h:189
void add_stdout(bool color=true, std::string level="")
Definition: Logging.cxx:48
std::string string
Definition: nybbler.cc:12
void set_level(std::string level, std::string which="")
Definition: Logging.cxx:90
static QStrList * l
Definition: config.cpp:1044
#define Assert
Definition: Testing.h:7
logptr_t logger(std::string name)
Definition: Logging.cxx:71
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
Definition: Main.h:22
std::shared_ptr< spdlog::logger > default_logger()
Definition: spdlog.h:149
void add_file(std::string filename, std::string level="")
Definition: Logging.cxx:42
void debug(const char *fmt, const Args &...args)
Definition: spdlog.h:183
int main(int argc, char *argv[])
Definition: test_logging.cxx:8
static bool * b
Definition: config.cpp:1043
static QCString * s
Definition: config.cpp:1042
void error(const char *fmt, const Args &...args)
Definition: spdlog.h:201