MCPcopy Create free account
hub / github.com/davisking/dlib / main

Function main

examples/logger_ex.cpp:35–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33logger dlog("example");
34
35int main()
36{
37 // Every logger has a logging level (given by dlog.level()). Each log message is tagged with a
38 // level and only levels equal to or higher than dlog.level() will be printed. By default all
39 // loggers start with level() == LERROR. In this case I'm going to set the lowest level LALL
40 // which means that dlog will print all logging messages it gets.
41 dlog.set_level(LALL);
42
43
44 // print our first message. It will go to cout because that is the default.
45 dlog << LINFO << "This is an informational message.";
46
47 // now print a debug message.
48 int variable = 8;
49 dlog << LDEBUG << "The integer variable is set to " << variable;
50
51 // the logger can be used pretty much like any ostream object. But you have to give a logging
52 // level first. But after that you can chain << operators like normal.
53
54 if (variable > 4)
55 dlog << LWARN << "The variable is bigger than 4! Its value is " << variable;
56
57
58
59 dlog << LINFO << "we are going to sleep for half a second.";
60 // sleep for half a second
61 dlib::sleep(500);
62 dlog << LINFO << "we just woke up";
63
64
65
66 dlog << LINFO << "program ending";
67}
68
69
70

Callers

nothing calls this directly

Calls 2

set_levelMethod · 0.80
sleepFunction · 0.50

Tested by

no test coverage detected