File: multiple-loggers.cpp

package info (click to toggle)
easyloggingpp 9.97.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,840 kB
  • sloc: cpp: 11,415; python: 2,336; sh: 337; makefile: 29
file content (31 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 //
 // This file is part of Easylogging++ samples
 // Very basic sample - log using multiple loggers
 //
 // Revision 1.0
 // @author mkhan3189
 //

#include "easylogging++.h"

INITIALIZE_EASYLOGGINGPP

int main(void) {

    el::Loggers::addFlag(el::LoggingFlag::MultiLoggerSupport); // Enables support for multiple loggers

    el::Loggers::getLogger("network"); // Register 'network' logger
    
    CLOG(INFO, "default", "network") << "My first log message that writes with network and default loggers";


    // Another way of doing this may be
    #define _LOGGER "default", "network"
    CLOG(INFO, _LOGGER) << "This is done by _LOGGER";

    // More practical way of doing this
    #define NETWORK_LOG(LEVEL) CLOG(LEVEL, _LOGGER)
    NETWORK_LOG(INFO) << "This is achieved by NETWORK_LOG macro";

    return 0;
}