MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / main

Function main

sample/main.cc:33–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31using namespace NanoLog::LogLevels;
32
33int main(int argc, char** argv) {
34 // Optional: Set the output location for the NanoLog system. By default
35 // the log will be output to ./compressedLog
36 NanoLog::setLogFile("/tmp/logFile");
37
38 // Optional optimization: pre-allocates thread-local data structures
39 // needed by NanoLog. This can be invoked once per new
40 // thread that will use the NanoLog system.
41 NanoLog::preallocate();
42
43 // Optional: Set the minimum LogLevel that log messages must have to be
44 // persisted. Valid from least to greatest values are
45 // DEBUG, NOTICE, WARNING, ERROR
46 NanoLog::setLogLevel(NOTICE);
47
48 NANO_LOG(DEBUG, "This message wont be logged since it is lower "
49 "than the current log level.");
50
51 // Log levels can be named explicitly if one does not import the LogLevels
52 // namespace with 'using'
53 NANO_LOG(NanoLog::DEBUG, "Another message.");
54
55 // All the standard printf specifiers (except %n) can be used
56 char randomString[] = "Hello World";
57 NANO_LOG(NOTICE, "A string, pointer, number, and float: '%s', %p, %d, %f",
58 randomString,
59 &randomString,
60 512,
61 3.14159);
62
63 // Even with width and length specifiers
64 NANO_LOG(NOTICE, "Shortend String: '%5s' and shortend float %0.2lf",
65 randomString,
66 3.14159);
67
68
69 runBenchmark();
70
71 // Optional: Flush all pending log messages to disk
72 NanoLog::sync();
73
74 // Optional: Gather statics generated by NanoLog
75 std::string stats = NanoLog::getStats();
76 printf("%s", stats.c_str());
77
78 // Optional: Prints NanoLog configuration parameters
79 NanoLog::printConfig();
80}
81
82void runBenchmark() {
83 const uint64_t RECORDS = 1000;

Callers

nothing calls this directly

Calls 8

setLogFileFunction · 0.85
preallocateFunction · 0.85
setLogLevelFunction · 0.85
NANO_LOGClass · 0.85
syncFunction · 0.85
getStatsFunction · 0.85
printConfigFunction · 0.85
runBenchmarkFunction · 0.70

Tested by

no test coverage detected