File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ In case of `LazyLogging` and `StrictLogging`, the underlying SLF4J logger is nam
7777these traits are mixed:
7878
7979``` scala
80- class MyClass extends LazyLogging {
80+ class LazyLoggingExample extends LazyLogging {
8181 logger.debug(" This is very convenient ;-)" )
8282
8383 logger.whenDebugEnabled {
@@ -87,6 +87,19 @@ class MyClass extends LazyLogging {
8787}
8888```
8989
90+ ``` scala
91+ class AnyLoggingExample extends AnyLogging {
92+ override protected val logger : Logger = Logger (" name" )
93+
94+ logger.info(" This is Any Logging ;-)" )
95+
96+ logger.whenInfoEnabled {
97+ println(" This would only execute when the info level is enabled." )
98+ (1 to 10 ).foreach(x => println(" Scala logging is great!" ))
99+ }
100+ }
101+ ```
102+
90103` LoggerTakingImplicit ` provides the same methods as ` Logger ` class, but with additional implicit parameter ` A ` .
91104During creation of the ` LoggerTakingImplicit ` evidence ` CanLog[A] ` is required.
92105It may be useful when contextual parameter (e.g. _ Correlation ID_ ) is being passed around and you would like to include it in the log messages:
You can’t perform that action at this time.
0 commit comments