Package io.spine.logging.flogger.context
Class LogLevelMap
- java.lang.Object
-
- io.spine.logging.flogger.context.LogLevelMap
-
public final class LogLevelMap extends Object
A hierarchical mapping from logger name toLevelused to override the configured log level during debugging. This class is designed to allow efficient (i.e. zero-allocation) resolution of the log level for a given logger.This class is immutable and thread safe.
- See Also:
- Original Java code of Google Flogger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLogLevelMap.BuilderBuilder for log level map which uses type safe class/package keys (but requires that they be present in the JVM at the time the map is created).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LogLevelMap.Builderbuilder()Returns a new builder for constructing aLogLevelMap.static LogLevelMapcreate(Level level)Returns an emptyLogLevelMapwith a single default level which will apply to all loggers.static LogLevelMapcreate(Map<String,? extends Level> map)Returns aLogLevelMapwhose entries correspond to the given map, and with the default value ofLevel.OFF.static LogLevelMapcreate(Map<String,? extends Level> map, Level defaultLevel)Returns aLogLevelMapwhose entries correspond to the given map.LevelgetLevel(String loggerName)Returns the log level for the specified logger, matching theloggerNameto an entry in the map, or the nearest parent in the naming hierarchy.LogLevelMapmerge(LogLevelMap other)Returns the union of this map with the given map.
-
-
-
Method Detail
-
builder
public static LogLevelMap.Builder builder()
Returns a new builder for constructing aLogLevelMap.
-
create
public static LogLevelMap create(Level level)
Returns an emptyLogLevelMapwith a single default level which will apply to all loggers.
-
create
public static LogLevelMap create(Map<String,? extends Level> map)
Returns aLogLevelMapwhose entries correspond to the given map, and with the default value ofLevel.OFF. The keys of the map must all be valid dot-separated logger names, and the values cannot benull.
-
create
public static LogLevelMap create(Map<String,? extends Level> map, Level defaultLevel)
Returns aLogLevelMapwhose entries correspond to the given map. The keys of the map must all be valid dot-separated logger names, and neither the values, nor the default value, can benull.
-
getLevel
public Level getLevel(String loggerName)
Returns the log level for the specified logger, matching theloggerNameto an entry in the map, or the nearest parent in the naming hierarchy. If the givenloggerNameis invalid, the default value is returned.
-
merge
public LogLevelMap merge(LogLevelMap other)
Returns the union of this map with the given map. Logging is enabled in the merged map if-and-only-if it was enabled in one of the maps it was created from.
-
-