Multiple levels of debug logging

The new Logging utility is very nice. However, for debug logging, I often want to have several levels of verbosity e.g.

Level 1 - function entry point
Level 2 - debug within function body
Level 3 - debug within some kind of loop

What would be the best way to achieve that?

You can create your own LogLevel.

For reference, the Debug level is defined as const Debug = LogLevel(-1000). Your custom level can then be defined as for example LogLevel(-999) for a higher importance (closer to Info) or e.g. LogLevel(-1001), which is closer to BelowMinLevel. You can then log with that level using @logmsg.

1 Like