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

Disable all logs using ELPP_DISABLE_LOGS #365

Closed
taschetto opened this issue Mar 27, 2016 · 12 comments
Closed

Disable all logs using ELPP_DISABLE_LOGS #365

taschetto opened this issue Mar 27, 2016 · 12 comments

Comments

@taschetto
Copy link

Greetings, folks.

I'm trying to disable logs whilst running my unit tests using ELPP_DISABLE_LOGS, but it doesn't work.

This feature is commented out in easylogging++.h. Is there any way that I can disable all logs?

Thank you in advance for your help.

@taschetto
Copy link
Author

@mkhan3189 please, could you provide any help on this question?

@taschetto
Copy link
Author

Moving to google/glog because of this issue. 👎 😞

@abumq
Copy link
Owner

abumq commented Apr 9, 2016

Disable "Global" log in configuration. Sorry i have no access to computer at the moment but you can see how configurations work in README

@abumq
Copy link
Owner

abumq commented Apr 9, 2016

@abumq
Copy link
Owner

abumq commented Apr 9, 2016

By the way how are you using this macro (the one in question)? It's suppose to be available throughout the application so it's beat to define it via compiler flag to be safe (using -D)

@fkahhaleh
Copy link

@taschetto
it is very easy to swtich off logging via the config file.
In the different sections
(i.e Global, Warning, Verbose...etc)
you can Enable/Disable the Log for that secion, and it has two optiosn, LogToFile and LogToConsole.

A partial excerpt from a real-config file used in one of my projects:
* GLOBAL:
   FORMAT               =  "%datetime %msg"
   FILENAME             =  "D:\output.log"
   ENABLED              =  true         <--- Each ENABLED should be false and you are good to go.
   TO_FILE              =  true
   TO_STANDARD_OUTPUT   =  true
   MILLISECONDS_WIDTH   =  6
   PERFORMANCE_TRACKING =  true
   MAX_LOG_FILE_SIZE    =  1048576 ##2097152 ## 2MB - Comment starts with two hashes (##)
   LOG_FLUSH_THRESHOLD  =  10 ## Flush after every 100logs
* WARNING:
   FORMAT               =  "%msg"
   FILENAME             =  "D:\X.log"
   ENABLED              =  true         <--- And this as well.
   TO_FILE              =  true
   TO_STANDARD_OUTPUT   =  false
   MILLISECONDS_WIDTH   =  6
   PERFORMANCE_TRACKING =  true
   MAX_LOG_FILE_SIZE    =  1048576 ##2097152 ## 2MB - Comment starts with two hashes (##)
   LOG_FLUSH_THRESHOLD  =  10 ## Flush after every 10 logs

P.S, make sure to remove the <----- explanation as it is not a comment and will cause parsing error.

@Woundorf
Copy link

I have found that the macro doesn't work when compiling with gcc, but it works correctly when using clang or MSVC. If you want an example you can see here one build with gcc which shows default logs although ELPP_DISABLE_LOGS is used, and two builds with clang where logs are effectively disabled.

The macro is defined just before including easylogging++.h in the file with the main() mehod.

@abumq
Copy link
Owner

abumq commented May 23, 2016

in multiple files project macros should be defined using -D flag of compiler rather than manually in header files.

@lasrod
Copy link

lasrod commented Aug 30, 2016

I can't use this preprocessor define either. Setting the ELPP_DISABLE_LOGS preprocessor flag does not turn off logging.

This macro should probably redefine LOG and CLOG macros to do nothing instead so that the internal structure of easyloggerpp is not run at all if this is defined.

I would like to completely turn off the logging in release mode and to have zero or close to zero impact on the performance of our code when this has been defined.

@goloap
Copy link

goloap commented Mar 30, 2017

Same here. Tried using ELPP_DISABLE_LOGS in VS2013 by including it in the preprocessor macros and it doesn't seem to have any effect.

@goloap
Copy link

goloap commented Mar 30, 2017

I've fixed this by changing 286 from
#define ELPP_LOGGING_ENABLED (!defined(ELPP_DISABLE_LOGS))

To:
#if defined(ELPP_DISABLE_LOGS)
#define ELPP_LOGGING_ENABLED 0
#else
#define ELPP_LOGGING_ENABLED 1
#endif

goloap pushed a commit to goloap/easyloggingpp that referenced this issue Mar 30, 2017
abumq added a commit that referenced this issue Mar 31, 2017
Fix issue #365. ELPP_DISABLE_LOGS not working in VS
apollo13 pushed a commit to apollo13/easyloggingpp that referenced this issue Apr 19, 2017
@taschetto
Copy link
Author

Closing issue as it is resolved and/or worked around. :)

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

6 participants