Skip to content

refactor(core): SpyLog rework

Flavien BRIDAULT requested to merge 611-deprecate-oslm_-methods into dev

Description

SpyLog has been unnecessarily complex for a long time. In this rework, we propose to:

  • deprecate the loglevel TRACE. Only SLM_TRACE_FUNC() remains, but its occurrences should never be committed.
  • deprecate OSLM_* macros in favor of SLM_* macros, which now take stringstreams as input (no performance penalty)
  • all loglevels are now always compiled, which means that the big bloat of SPYLOG_* CMake variables were removed.
  • occurrences of OSLM_* macros were replaced by SLM_* macros
  • occurrences of O?SLM_TRACE* macros were removed or replaced by higher levels logging macros
  • the default displayed log level is now WARN
  • the path of files displayed in the output was shortened to keep the minimum information needed: namespace(s), source file.

People are now encouraged to be smarter in the way they use the logging levels:

  • ERROR: when something unexpected occurs, but keep in mind this is for developpers. To handle a real error and inform the user, please use GUI features.
  • WARN: when something that is potentially harmful happens.
  • INFO: allows keeping track of important events in the code. Only meaningful information for all developers should be kept.
  • DEBUG: allows debugging the code, to display internal states, variables, etc... It is not recommended to let such macros in production code.

In any case, logging macros in tight loops should never be committed into production code. They are the only cause of performance penalty.

Remember the default displayed can be changed anytime with --log-* arguments on fwlauncher command line. This works with application shortcuts. Ex:

bin/tuto03dataservice --log-debug

People are also encouraged to filter out the output of the logs, either directly on the command line, i.e. :

bin/tuto01basic --log-debug 2> >(grep fwServices >&2)

or using a third application, like glogg (available on all platforms, apt install glogg on Mint. Remember to output the log in a file:

bin/tuto03dataservice --log-info --flog

and then launch glogg on SLM.log (or other path if you change it using --log-output:

image

Closes #611 (closed) #88 (closed)

How to test it?

Test some apps with differents log levels on the command line.

Edited by Flavien BRIDAULT

Merge request reports