spdlog icon indicating copy to clipboard operation
spdlog copied to clipboard

Is it possible to create new logging levels?

Open ruipacheco opened this issue 9 years ago • 7 comments

I'd like to add logging levels to the existing ones. I'd like to give my users to use a debug level while I'd like to have a debug1() or debug_developer() for myself. The idea being that users should be able to have access to information about the inner works of the program but some types of information should only be viewed at development time.

How easy is it to add new logging levels?

ruipacheco avatar Mar 22 '17 13:03 ruipacheco

I'd be interested in something like this too. As it stands, debug and trace levels are good for two levels of granularity for debug tracing, but I can easily see more than two levels being useful.

dotnwat avatar Apr 19 '17 14:04 dotnwat

which log levels are you missing? I think custom log levels could cause complications to both code and the log files

gabime avatar Apr 19 '17 19:04 gabime

I'd like more than one level of trace. If a customer reports a bug I'd ideally send them a secret key, have them restart the app with the key in the configuration and suddenly all sorts of new values would be logged. The key itself would be customer specific.

Take a look at the number of debug levels Postgres has: https://www.postgresql.org/docs/9.0/static/runtime-config-logging.html#RUNTIME-CONFIG-SEVERITY-LEVELS

ruipacheco avatar Apr 20 '17 08:04 ruipacheco

Very relevant reddit discussion from today..

gabime avatar Apr 20 '17 14:04 gabime

For myself I don't care so much about new semantically named log levels--the current set is sufficient--what i'd like is the ability to assign a numeric value to, say, debug messages, that can be used when setting the log level. For instance debug(0, "normal debug") vs debug(20, "very verbose debug"). I realize that trace level is probably meant for this, but at least for myself, I have a bit more of a continuous range of log levels within the debug level. Not a game changer, just a thought.

dotnwat avatar Apr 20 '17 14:04 dotnwat

In my branch "https://github.com/vwbij/spdlog" I have invewnted log levels like this. I have decided to use them parallel to the existing level system, it is another way to do message filtering and may be used parallel or instead of the log level concept.

vwbij avatar Apr 21 '17 05:04 vwbij

I would like this too. Currently I use zlog, which has user-defined levels and my code has: CRAZY, TRACE, DEBUG, INFO, ERROR in rising order of severity. Numeric levels would work for me. CRAZY logging only works because I use categories, so when things turn to custard I can turn on CRAZY logging only for the area of interest. Normally it's #defined out of the build (which drops the exe size by ~30%).

DigiTester avatar Oct 09 '17 23:10 DigiTester