File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
src/main/scala/com/typesafe/scalalogging Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1616
1717package com .typesafe .scalalogging
1818
19- import org .slf4j .{ LoggerFactory , Marker , Logger => Underlying }
19+ import org .slf4j .{LoggerFactory , Marker , Logger => Underlying }
20+
21+ import scala .reflect .ClassTag
2022
2123/**
2224 * Companion for [[Logger ]], providing a factory for [[Logger ]]s.
@@ -29,11 +31,30 @@ object Logger {
2931 def apply (underlying : Underlying ): Logger =
3032 new Logger (underlying)
3133
34+ /** Create a [[Logger ]] for the given name.
35+ * Example:
36+ * {{{
37+ * val logger = Logger("application")
38+ * }}}
39+ */
40+ def apply (name : String ): Logger =
41+ new Logger (LoggerFactory .getLogger(name))
42+
3243 /**
3344 * Create a [[Logger ]] wrapping the created underlying `org.slf4j.Logger`.
3445 */
3546 def apply (clazz : Class [_]): Logger =
3647 new Logger (LoggerFactory .getLogger(clazz.getName))
48+
49+ /** Create a [[Logger ]] for the runtime class wrapped by the implicit class
50+ * tag parameter.
51+ * Example:
52+ * {{{
53+ * val logger = Logger[MyClass]
54+ * }}}
55+ */
56+ def apply [T ](implicit ct : ClassTag [T ]): Logger =
57+ new Logger (LoggerFactory .getLogger(ct.runtimeClass.getName.stripSuffix(" $" )))
3758}
3859
3960/**
You can’t perform that action at this time.
0 commit comments