encfs/vendor/github.com/muflihun/easyloggingpp/samples/STL/default-configurations.cpp
Valient Gough 5f0806c5cc Add "easylogging" from "https://github.com/muflihun/easyloggingpp@master"
git-vendor-name: easylogging
git-vendor-dir: vendor/github.com/muflihun/easyloggingpp
git-vendor-repository: https://github.com/muflihun/easyloggingpp
git-vendor-ref: master
2017-08-05 23:23:41 -07:00

35 lines
1.2 KiB
C++

//
// This file is part of Easylogging++ samples
//
// Demonstrates setting default configurations for existing and future loggers
//
// Revision 1.1
// @author mkhan3189
//
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
using namespace el;
int main(void) {
Configurations c;
c.setGlobally(ConfigurationType::Format, "[%logger] %level: %msg");
c.setGlobally(ConfigurationType::Filename, "/tmp/logs/custom.log");
// Set default configuration for any future logger - existing logger will not use this configuration unless
// either true is passed in second argument or set explicitly using Loggers::reconfigureAllLoggers(c);
Loggers::setDefaultConfigurations(c);
LOG(INFO) << "Set default configuration but existing loggers not updated yet"; // Logging using trivial logger
Loggers::getLogger("testDefaultConf");
CLOG(INFO, "testDefaultConf") << "Logging using new logger 1"; // You can also use CINFO << "..."
// Now setting default and also resetting existing loggers
Loggers::setDefaultConfigurations(c, true);
LOG(INFO) << "Existing loggers updated as well";
Loggers::getLogger("testDefaultConf2");
CLOG(INFO, "testDefaultConf2") << "Logging using new logger 2";
return 0;
}