diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-05-09 16:32:34 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-05-09 16:32:34 +0200 |
commit | d2cfd71627f38419f0eba31708ca5ec97b8267c6 (patch) | |
tree | 871735c60cbf18077c86a954d3ff0f96984235da /lib | |
parent | c876b304ba72e93dac4737dd98f003f9ee94d9b8 (diff) | |
parent | 5da7f28990fc535ff25a1e8aee780f525d2331c8 (diff) | |
download | Nim-d2cfd71627f38419f0eba31708ca5ec97b8267c6.tar.gz |
Merge pull request #4131 from niv/pr-logging-syslogish
pure/logging: add notice level, suggest usecases
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/logging.nim | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim index f602ce31d..8a0d2fedd 100644 --- a/lib/pure/logging.nim +++ b/lib/pure/logging.nim @@ -54,6 +54,7 @@ type lvlAll, ## all levels active lvlDebug, ## debug level (and any above) active lvlInfo, ## info level (and any above) active + lvlNotice, ## info notice (and any above) active lvlWarn, ## warn level (and any above) active lvlError, ## error level (and any above) active lvlFatal, ## fatal level (and any above) active @@ -61,7 +62,7 @@ type const LevelNames*: array [Level, string] = [ - "DEBUG", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE" + "DEBUG", "DEBUG", "INFO", "NOTICE", "WARN", "ERROR", "FATAL", "NONE" ] defaultFmtStr* = "$levelname " ## default format string @@ -258,22 +259,47 @@ template log*(level: Level, args: varargs[string, `$`]) = template debug*(args: varargs[string, `$`]) = ## Logs a debug message to all registered handlers. + ## + ## Messages that are useful to the application developer only and are usually + ## turned off in release. log(lvlDebug, args) template info*(args: varargs[string, `$`]) = ## Logs an info message to all registered handlers. + ## + ## Messages that are generated during the normal operation of an application + ## and are of no particular importance. Useful to aggregate for potential + ## later analysis. log(lvlInfo, args) +template notice*(args: varargs[string, `$`]) = + ## Logs an notice message to all registered handlers. + ## + ## Semantically very similar to `info`, but meant to be messages you want to + ## be actively notified about (depending on your application). + ## These could be, for example, grouped by hour and mailed out. + log(lvlNotice, args) + template warn*(args: varargs[string, `$`]) = ## Logs a warning message to all registered handlers. + ## + ## A non-error message that may indicate a potential problem rising or + ## impacted performance. log(lvlWarn, args) template error*(args: varargs[string, `$`]) = ## Logs an error message to all registered handlers. + ## + ## A application-level error condition. For example, some user input generated + ## an exception. The application will continue to run, but functionality or + ## data was impacted, possibly visible to users. log(lvlError, args) template fatal*(args: varargs[string, `$`]) = ## Logs a fatal error message to all registered handlers. + ## + ## A application-level fatal condition. FATAL usually means that the application + ## cannot go on and will exit (but this logging event will not do that for you). log(lvlFatal, args) proc addHandler*(handler: Logger) = |