- All Superinterfaces:
AutoCloseable
,LogLifecycle
- All Known Subinterfaces:
LogRouter.RootRouter
,LogRouter.Router
- All Known Implementing Classes:
LogRouter.AbstractRouter
public sealed interface LogRouter
extends LogLifecycle
permits LogRouter.RootRouter, LogRouter.Router (not exhaustive)
Routes messages to a publisher by providing a
LogRouter.Route
from a logger name and
level.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
A user supplied router usually for filtering or transforming purposes.static interface
Root router is a router that has child routers.static interface
A route is similar to a SLF4J Logger or System Logger but has a much simpler contract.static enum
Router flags for adhoc router customization.static interface
Router routes messages to a publisher. -
Field Summary
Fields inherited from interface io.jstach.rainbowgum.LogLifecycle
SHUTDOWN
-
Method Summary
Modifier and TypeMethodDescriptiondefault LogEvent.Builder
eventBuilder
(String loggerName, System.Logger.Level level) Creates (or reuses in the case of logging off) an event builder.static LogRouter.RootRouter
global()
Global router which is always available.static LogRouter
ofLevel
(LogEventLogger logger, System.Logger.Level level) Creates a static router based on the level.route
(String loggerName, System.Logger.Level level) Finds a route.Methods inherited from interface io.jstach.rainbowgum.LogLifecycle
close, start
-
Method Details
-
route
Finds a route.- Parameters:
loggerName
- topic.level
- level.- Returns:
- route never
null
.
-
eventBuilder
Creates (or reuses in the case of logging off) an event builder.- Parameters:
loggerName
- logger name of the event.level
- level that the event should be set to.- Returns:
- builder.
- API Note
- using the builder is slightly slower and possibly more garbage (if the
builder is not marked for escape analysis) than just manually checking
LogRouter.Route.isEnabled()
and constructing the event using the LogEvent static "of
" factory methods.
-
global
Global router which is always available.- Returns:
- global root router.
-
ofLevel
Creates a static router based on the level. Use aLevelResolver
to resolve the level first.- Parameters:
logger
- to publish events that are equal or above level.level
- threshold of the router.- Returns:
- immutable static router.
- API Note
- This method is for facades that do not have named level methods but are passed the level on every log method like the System Logger.
-