encfs/vendor/github.com/muflihun/easyloggingpp/samples/STL/log-dispatch-callback.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

43 lines
1.0 KiB
C++

//
// This file is part of Easylogging++ samples
// Demonstrates how to use log dispatch callback
//
// Revision 1.0
// @author mkhan3189
//
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
class MyHandler : public el::LogDispatchCallback {
public:
void handle(const el::LogDispatchData*) {
// NEVER DO LOG FROM HANDLER!
// LOG(INFO) << "Test MyHandler " << msg;
}
};
class MyHtmlHandler : public el::LogDispatchCallback {
public:
MyHtmlHandler() {
el::Loggers::getLogger("html"); // register
}
void handle(const el::LogDispatchData*) {
// NEVER DO LOG FROM HANDLER!
// CLOG(INFO, "html") << data->logMessage()->message();
std::cout << "Test handler" << std::endl;
}
};
int main(void) {
el::Helpers::installLogDispatchCallback<MyHandler>("MyHandler");
el::Helpers::installLogDispatchCallback<MyHtmlHandler>("MyHtmlHandler");
LOG(INFO) << "My first log message";
LOG(INFO) << "My second log message";
return 0;
}