easyloggingpp icon indicating copy to clipboard operation
easyloggingpp copied to clipboard

performance logging TIMED_SCOPE(timerBlkObj) to a file

Open yalov opened this issue 2 years ago • 0 comments

could someone provide example how to put all performance logging into a file a1.txt?

looks like this example is doing something different and more complicated: https://github.com/abumq/easyloggingpp/blob/master/samples/STL/custom-performance-output.cpp I have not understood how to use that.

This code output performance to console, how to make it output to second logger (--a1) ?

easylogging++.conf

-- default
	* GLOBAL:
		FORMAT               =  "%datetime{%Y-%M-%d %H:%m:%s.%g}      %level: %msg"
		FILENAME             =  "log.txt"
		ENABLED              =  true
		TO_FILE              =  true
		TO_STANDARD_OUTPUT   =  true
		SUBSECOND_PRECISION  =  3
		PERFORMANCE_TRACKING =  true
		MAX_LOG_FILE_SIZE    =  268435456 ## 256MB
		LOG_FLUSH_THRESHOLD  =  100 

--a1
	* GLOBAL:
		FORMAT               =  "%msg"
		FILENAME             =  "a1.txt"
		TO_STANDARD_OUTPUT   =  true
		PERFORMANCE_TRACKING =  true

main.cpp

#include "easylogging++.h"
#include <chrono>
#include <thread>
using namespace std::chrono_literals;

INITIALIZE_EASYLOGGINGPP

int main() {
	el::Loggers::addFlag(el::LoggingFlag::MultiLoggerSupport);
	el::Loggers::configureFromGlobal("./easylogging++.conf");

	for (int i = 0; i <= 50; ++i) {
		TIMED_SCOPE(timerBlkObj, "a1"); // this need to go to a1.txt and to console
		std::this_thread::sleep_for(10ms);
	}

	return 0;
}

yalov avatar Aug 22 '23 13:08 yalov