akka.event
Interface LogSource<T>


public interface LogSource<T>

This trait defines the interface to be provided by a &ldquo;log source formatting rule&rdquo; as used by Logging&rsquo;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&rsquo;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 = ActorSyste("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.


Method Summary
 java.lang.String genString(T t)
           
 java.lang.String genString(T t, ActorSystem system)
           
 java.lang.Class<?> getClazz(T t)
           
 

Method Detail

genString

java.lang.String genString(T t)

genString

java.lang.String genString(T t,
                           ActorSystem system)

getClazz

java.lang.Class<?> getClazz(T t)