Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/main/scala/com/typesafe/scalalogging/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.typesafe.scalalogging

import org.slf4j.{ LoggerFactory, Marker, Logger => Underlying }
import org.slf4j.{LoggerFactory, Marker, Logger => Underlying}

import scala.reflect.ClassTag

/**
* Companion for [[Logger]], providing a factory for [[Logger]]s.
Expand All @@ -29,11 +31,30 @@ object Logger {
def apply(underlying: Underlying): Logger =
new Logger(underlying)

/** Create a [[Logger]] for the given name.
* Example:
* {{{
* val logger = Logger("application")
* }}}
*/
def apply(name: String): Logger =
new Logger(LoggerFactory.getLogger(name))

/**
* Create a [[Logger]] wrapping the created underlying `org.slf4j.Logger`.
*/
def apply(clazz: Class[_]): Logger =
new Logger(LoggerFactory.getLogger(clazz.getName))

/** Create a [[Logger]] for the runtime class wrapped by the implicit class
* tag parameter.
* Example:
* {{{
* val logger = Logger[MyClass]
* }}}
*/
def apply[T](implicit ct: ClassTag[T]): Logger =
new Logger(LoggerFactory.getLogger(ct.runtimeClass.getName.stripSuffix("$")))
}

/**
Expand Down