Called with a debug message and possibly a throwable that caused the issue in question.
Called with a debug message and possibly a throwable that caused the issue in question. Should DEBUG log the message and the throwable.
Exists in order to abstract away logger abstractions. Abstractception, as it were.
Called with an error message and possibly a throwable that caused the error in question.
Called with an error message and possibly a throwable that caused the error in question. Should ERROR log the message and the throwable.
Exists in order to abstract away logger abstractions. Abstractception, as it were.
Called with an info message and possibly a throwable that caused the issue in question.
Called with an info message and possibly a throwable that caused the issue in question. Should INFO log the message and the throwable.
Exists in order to abstract away logger abstractions. Abstractception, as it were.
Called with a trace message and possibly a throwable that caused the issue in question.
Called with a trace message and possibly a throwable that caused the issue in question. Should TRACE log the message and the throwable.
Exists in order to abstract away logger abstractions. Abstractception, as it were.
Called with a warn message and possibly a throwable that caused the issue in question.
Called with a warn message and possibly a throwable that caused the issue in question. Should WARN log the message and the throwable.
Exists in order to abstract away logger abstractions. Abstractception, as it were.
Mix this trait in to get some low-cost implicits for logging boxes easily. The consumer will need to implement a
logBoxErrormethod to log messages with an optionalThrowable, as well as its related friends for trace, debug, info, and warn levels. This allows abstracting out where and what the actual logger is.With this mixed in, boxes will have
logFailureandlogFailuremethods. The first logs allFailures as well asEmpty. The second logs onlyFailures andParamFailures, treatingEmptyas a valid value. These both log their respective items at ERROR level. You can also usetraceLog*,debugLog*,infoLog*, andwarnLog*if you want to log at other levels (e.g., you can useinfoLogFailureto log anEmptyorFailureatINFOlevel).All of these return the box unchanged, so you can continue to use it in
forcomprehensions, callopenOron it, etc.There is an implementation for anyone who wants to use Lift's
Loggabletrait calledLoggableBoxLogging. Another implementaiton is available for use with a plain SLF4J logger,SLF4JBoxLogging. You can also implement a version for any other logging adapter. Lastly, you can simply importBoxLogging._to get the methods available at a top level; however, note that using them this way will lose information about where the log message came from.Here is an example of how you might use this in system that executes a third- party service and notifies another system of failures.