Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance logging TIMED_SCOPE(timerBlkObj) to a file #839

Open
yalov opened this issue Aug 22, 2023 · 0 comments
Open

performance logging TIMED_SCOPE(timerBlkObj) to a file #839

yalov opened this issue Aug 22, 2023 · 0 comments

Comments

@yalov
Copy link

yalov commented Aug 22, 2023

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant