fpillet / NSLogger

A modern, flexible logging tool
Other
5k stars 573 forks source link

Enabling remote logging on demand in release #305

Open Donnit opened 3 years ago

Donnit commented 3 years ago

Hi! I just discovered this great pod, and I managed to make it working with success in Debug configuration. I've found that macros like LoggerApp LoggerError etc. are defined within the preprocessor macro DEBUG, so they are available only for debug builds. I would like them to be available also on release builds, only when the user activate remote logging.

What would be the best practice to achieve this behaviour? What I would do:

#define MyLoggerError(level, ...) \ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remotelogging"]) LogMessageF(__FILE__, __LINE__, __FUNCTION__, @"Error", level, __VA_ARGS__)

I wonder if this check would slow down performance even if the boolean is set to NO. Using the DEBUG preprocessor LoggerError is replaced with while(0) {} and I don't think it costs any time in runtime.

Thank you very much!