Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to create a function like this:
Alogging::ALogger::getInstance()->setLoggingLevelByModule(IAP::module_name, Alogging::ALogger::level::LEVEL);
and it disable all logs from given module_name only

What I have tried:

It is explained as a comment in the file https://github.com/gabime/spdlog/blob/v1.x/include/spdlog/spdlog.h :



githubRepository: https://github.com/Bugsfounder/DisableAllLogFromHeaderFiles.git[^]
Posted
Updated 24-Mar-22 7:09am
v5

So go and create it! Or are you asking someone here to do your work for you? We'd have to research that repository and figure out what it means by a module, and then look at the code for ALogger, which appears to be a singleton.

Unless someone is in a very generous mood, you usually have to show some actual work before you'll get help.
 
Share this answer
 
Comments
Bugs Founder 24-Mar-22 12:15pm    
github code is here see if you are able to done this: https://github.com/Bugsfounder/piModule_Personal-master.git
Greg Utas 24-Mar-22 12:19pm    
There's a lot of code in there. I doubt anyone will sift through all of it and do this for you.
Bugs Founder 24-Mar-22 12:23pm    
okay
Bugs Founder 24-Mar-22 12:29pm    
can u look in this code and try to implement the logic to disable logs from "myExample.h" only. when i run "myExample.cpp" it logs only those logs which not apearing from any another header file
Greg Utas 24-Mar-22 12:39pm    
No. You didn't even tell me where myExample.cpp is located. I looked a bit but couldn't even find it! Stop wasting people's time.
If I understand this correctly, there is no simple way to do it. You want to disable logs coming from a specific file, but when you call one of these logging functions, it has no way to know which file is generating the log. The filename would have to be passed to the logging function, and the log system would also have to provide a function that takes a filename and bool (for disabling/enabling logs from that file) to maintain a simple database that determines whether a log should be generated.

The other question is whether you'd even be happy with the end result. Let's say that two files, A and B, use a third file, C. If something in A calls something in C, do you want to suppress the log if logs from A are suppressed? Logically, you might, because it has to do with work occurring in A. But trying to do this would be even more complicated.
 
Share this answer
 
Comments
Bugs Founder 24-Mar-22 13:18pm    
please, can u try to implement a function for me that you are saying in your first paragraph?
Bugs Founder 24-Mar-22 13:34pm    
yaa I know it is complicated but can you help me to solve this?
Greg Utas 24-Mar-22 13:35pm    
You have to change the log system to add a filename (const char*) to each logging function, and then define a SetLogsForFile(const char* filename, bool onoff) function that front-ends a database that each logging function consults to see if the log should be suppressed.

That repository has a lot of code written by someone who knows how to code. If you just cloned it and want to play around with it, you should take on something easier first.

I am NOT writing the code.
Bugs Founder 24-Mar-22 13:42pm    
this is a part of a project that me and my team members working on for a long period of time. we are stuck on this particular problem.
Bugs Founder 24-Mar-22 13:50pm    
thanks for your suggestion I'm going to work on your idea.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900