trait LogSource[-T] extends AnyRef

This trait defines the interface to be provided by a “log source formatting rule” as used by akka.event.Logging’s apply/create method.

See the companion object for default implementations.

Example:

trait MyType { // as an example
  def name: String
}

implicit val myLogSourceType: LogSource[MyType] = new LogSource[MyType] {
  def genString(a: MyType) = a.name
}

class MyClass extends MyType {
  val log = Logging(eventStream, this) // will use "hallo" as logSource
  def name = "hallo"
}

The second variant is used for including the actor system’s address:

trait MyType { // as an example
  def name: String
}

implicit val myLogSourceType: LogSource[MyType] = new LogSource[MyType] {
  def genString(a: MyType) = a.name
  def genString(a: MyType, s: ActorSystem) = a.name + "," + s
}

class MyClass extends MyType {
  val sys = ActorSystem("sys")
  val log = Logging(sys, this) // will use "hallo,akka://sys" as logSource
  def name = "hallo"
}

The default implementation of the second variant will just call the first.

Annotations
@implicitNotFound( ... )
Source
Logging.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LogSource
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def genString(t: T): String

Concrete Value Members

  1. def genString(t: T, system: ActorSystem): String
  2. def getClazz(t: T): Class[_]