INTERNAL API
INTERNAL API
Watches all actors which subscribe on the given event stream, and unsubscribes them from it when they are Terminated.
Can be mixed into an EventBus to specify that the Classifier type is ActorRef
Represents an EventBus where the Subscriber type is ActorRef
akka.event.LoggingAdapter that publishes akka.event.Logging.LogEvent to event stream.
Default LoggingFilter that uses the logLevel of the eventStream
, which
initial value is defined in configuration.
Default LoggingFilter that uses the logLevel of the eventStream
, which
initial value is defined in configuration. The logLevel eventStream
can be
changed while the system is running.
LoggingAdapter extension which adds MDC support.
LoggingAdapter extension which adds MDC support. Only recommended to be used within Actors as it isn't thread safe.
This is a “marker” class which is inserted as originator class into akka.event.Logging.LogEvent when the string representation was supplied directly.
Represents the base type for EventBuses Internally has an Event type, a Classifier type and a Subscriber type
Represents the base type for EventBuses Internally has an Event type, a Classifier type and a Subscriber type
For the Java API, see akka.event.japi.*
An Akka EventStream is a pub-sub stream of events both system and user generated, where subscribers are ActorRefs and the channels are Classes and Events are any java.lang.Object.
An Akka EventStream is a pub-sub stream of events both system and user generated, where subscribers are ActorRefs and the channels are Classes and Events are any java.lang.Object. EventStreams employ SubchannelClassification, which means that if you listen to a Class, you'll receive any message that is of that type or a subtype.
The debug flag in the constructor toggles if operations on this EventStream should also be published as Debug-Events
INTERNAL API
INTERNAL API
Watches all actors which subscribe on the given eventStream, and unsubscribes them from it when they are Terminated.
Assumptions note: We do not guarantee happens-before in the EventStream when 2 threads subscribe(a) / unsubscribe(a) on the same actor, thus the messages sent to this actor may appear to be reordered - this is fine, because the worst-case is starting to needlessly watch the actor which will not cause trouble for the stream. This is a trade-off between slowing down subscribe calls * because of the need of linearizing the history message sequence and the possibility of sometimes watching a few actors too much - we opt for the 2nd choice here.
DO NOT INHERIT: Class is open only for use by akka-slf4j
DO NOT INHERIT: Class is open only for use by akka-slf4j
This trait defines the interface to be provided by a “log source formatting
rule” as used by akka.event.Logging’s apply
/create
method.
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.
Logging wrapper to make nicer and optimize: provide template versions which evaluate .toString only if the log level is actually enabled.
Logging wrapper to make nicer and optimize: provide template versions which evaluate .toString only if the log level is actually enabled. Typically used by obtaining an implementation from the Logging object:
val log = Logging(<bus>, <source object>) ... log.info("hello world!")
All log-level methods support simple interpolation templates with up to four
arguments placed by using {}
within the template (first string
argument):
log.error(exception, "Exception while processing {} in state {}", msg, state)
More than four arguments can be defined by using an Array
with the method with
one argument parameter.
This trait brings log level handling to the EventStream: it reads the log levels for the initial logging (StandardOutLogger) and the loggers & level for after-init logging, possibly keeping the StandardOutLogger enabled if it is part of the configured loggers.
This trait brings log level handling to the EventStream: it reads the log levels for the initial logging (StandardOutLogger) and the loggers & level for after-init logging, possibly keeping the StandardOutLogger enabled if it is part of the configured loggers. All configured loggers are treated as system services and managed by this trait, i.e. subscribed/unsubscribed in response to changes of LoggingBus.logLevel.
Filter of log events that is used by the LoggingAdapter
before
publishing log events to the eventStream
.
Filter of log events that is used by the LoggingAdapter
before
publishing log events to the eventStream
. It can perform
fine grained filtering based on the log source.
Note that the EventStream will only subscribe loggers
to the events
corresponding to the logLevel
of the EventStream
. Therefore it is good
practice that the LoggingFilter
implementation first filters using the
logLevel
of the EventStream
before applying more fine grained filters.
In retrospect should have been abstract, but we cannot change that without breaking binary compatibility
In retrospect should have been abstract, but we cannot change that without breaking binary compatibility
This decorator adds invocation logging to a Receive function.
Maps Subscribers to Classifiers using equality on Classifier to store a Set of Subscribers (hence the need for compareSubscribers) Maps Events to Classifiers through the classify-method (so it knows who to publish to)
Maps Subscribers to Classifiers using equality on Classifier to store a Set of Subscribers (hence the need for compareSubscribers) Maps Events to Classifiers through the classify-method (so it knows who to publish to)
The compareSubscribers need to provide a total ordering of the Subscribers
Maps ActorRefs to ActorRefs to form an EventBus where ActorRefs can listen to other ActorRefs.
Maps ActorRefs to ActorRefs to form an EventBus where ActorRefs can listen to other ActorRefs.
All subscribers will be watched by an akka.event.ActorClassificationUnsubscriber
and unsubscribed when they terminate.
The unsubscriber actor will not be stopped automatically, and if you want to stop using the bus you should stop it yourself.
LoggingAdapter extension which adds Marker support.
Can be mixed into an EventBus to specify that the Classifier type is a Function from Event to Boolean (predicate)
Maps Classifiers to Subscribers and selects which Subscriber should receive which publication through scanning through all Subscribers through the matches(classifier, event) method
Maps Classifiers to Subscribers and selects which Subscriber should receive which publication through scanning through all Subscribers through the matches(classifier, event) method
Note: the compareClassifiers and compareSubscribers must together form an absolute ordering (think java.util.Comparator.compare)
Classification which respects relationships between channels: subscribing to one channel automatically and idempotently subscribes to all sub-channels.
This object holds predefined formatting rules for log sources.
This object holds predefined formatting rules for log sources.
In case an akka.actor.ActorSystem is provided, the following apply:
String
as source will append "(<system address>)" and use the resultClass
will extract its simple name, append "(<system address>)" and use the resultIn case a akka.event.LoggingBus is provided, the following apply:
String
as source will be used as isClass
will extract its simple nameMain entry point for Akka logging: log levels and message types (aka channels) defined for the main transport medium, the main event bus.
Main entry point for Akka logging: log levels and message types (aka channels) defined for the main transport medium, the main event bus. The recommended use is to obtain an implementation of the Logging trait with suitable and efficient methods for generating log events:
val log = Logging(<bus>, <source object>)
...
log.info("hello world!")
The source object is used in two fashions: its Class[_]
will be part of
all log events produced by this logger, plus a string representation is
generated which may contain per-instance information, see apply
or create
below.
Loggers are attached to the level-specific channels Error
,
Warning
, Info
and Debug
as
appropriate for the configured (or set) log level. If you want to implement
your own, make sure to handle these four event types plus the InitializeLogger
message which is sent before actually attaching it to the logging bus.
Logging is configured by setting (some of) the following:
akka {
loggers = ["akka.slf4j.Slf4jLogger"] # for example
loglevel = "INFO" # used when normal logging ("loggers") has been started
stdout-loglevel = "WARN" # used during application start-up until normal logging is available
}
NoLogging is a LoggingAdapter that does absolutely nothing – no logging at all.
NoLogging is a MarkerLoggingAdapter that does absolutely nothing – no logging at all.