You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to have one PreRollOutCallback callback per logger?
If not, how can I distinguish which logger called it? The input arguments of the PreRollOutCallback function are file name and size.
But the file name is form the conf file and can be anything.
#include "easylogging++.h"
#include <filesystem>
INITIALIZE_EASYLOGGINGPP
void rolloutHandler(const char* filename, std::size_t size) {
// SHOULD NOT LOG ANYTHING HERE BECAUSE LOG FILE IS CLOSED!
std::cout << "************** Rolling out [" << filename << "] because it reached [" << size << " bytes]" << std::endl;
// Here I need to distinguish between default logger and second logger. Their names can change in conf
}
int main(int, char**) {
el::Configurations conf1("log1.conf");
el::Loggers::reconfigureLogger("default",conf1);
el::Configurations conf2("log2.conf");
el::Loggers::reconfigureLogger("second",conf2);
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
el::Helpers::installPreRollOutCallback(rolloutHandler); // Can we have callback per logger
for (int i = 0; i < 100; ++i){
LOG(INFO) << "Log with default " << i;
CLOG(INFO, "second") << "Log with second " << i;
}
el::Helpers::uninstallPreRollOutCallback();
return 0;
}
The text was updated successfully, but these errors were encountered:
ramezanifar
changed the title
how to have dedicated PreRollOutCallback callback for each logger
how to have a PreRollOutCallback callback for each logger
Nov 25, 2024
ramezanifar
changed the title
how to have a PreRollOutCallback callback for each logger
how to distinguish which logger called the PreRollOutCallback?
Nov 25, 2024
Is it possible to have one
PreRollOutCallback
callback per logger?If not, how can I distinguish which logger called it? The input arguments of the
PreRollOutCallback
function are file name and size.But the file name is form the conf file and can be anything.
The text was updated successfully, but these errors were encountered: