Class FluentLogger2
- java.lang.Object
-
- com.google.common.flogger.AbstractLogger<FluentLogger2.Api>
-
- com.google.common.flogger.FluentLogger2
-
public final class FluentLogger2 extends AbstractLogger<FluentLogger2.Api>
The default implementation ofAbstractLoggerwhich returns the basicLoggingApiand uses the default parser and system configured backend.Note that when extending the logging API or specifying a new parser, you will need to create a new logger class (rather than extending this one). Unlike the
LogContextclass, which must be extended in order to modify the logging API, this class is not generified and thus cannot be modified to produce a different logging API.The choice to prevent direct extension of loggers was made deliberately to ensure that users of a specific logger implementation always get the same behavior.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFluentLogger2.ApiThe non-wildcard, fully specified, logging API for this logger.
-
Constructor Summary
Constructors Constructor Description FluentLogger2(LoggerBackend backend)Creates a new fluent logger instance with the specified backend.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FluentLogger2.Apiat(Level level)Returns a fluent logging API appropriate for the specified log level.static FluentLogger2forEnclosingClass()Returns a new logger instance which parses log messages using printf format for the enclosing class using the system default logging backend.-
Methods inherited from class com.google.common.flogger.AbstractLogger
atConfig, atFine, atFiner, atFinest, atInfo, atSevere, atWarning, getName, isLoggable
-
-
-
-
Constructor Detail
-
FluentLogger2
public FluentLogger2(LoggerBackend backend)
Creates a new fluent logger instance with the specified backend.- API Note:
- This constructor used to be package-private in the original Flogger implementation.
This, in turn, required reflection-based creation of new instances of this class in
io.spine.logging.JvmLoggerFactoryKt. Now, as we aggregate the Flogger code, we open the constructor for simplicity.
-
-
Method Detail
-
forEnclosingClass
public static FluentLogger2 forEnclosingClass()
Returns a new logger instance which parses log messages using printf format for the enclosing class using the system default logging backend.
-
at
public FluentLogger2.Api at(Level level)
Description copied from class:AbstractLoggerReturns a fluent logging API appropriate for the specified log level.If a logger implementation determines that logging is definitely disabled at this point then this method is expected to return a "no-op" implementation of that logging API, which will result in all further calls made for the log statement to being silently ignored.
A simple implementation of this method in a concrete subclass might look like:
whereboolean isLoggable = isLoggable(level); boolean isForced = Platform.shouldForceLogging(getName(), level, isLoggable); return (isLoggable | isForced) ? new SubContext(level, isForced) : NO_OP;NO_OPis a singleton, no-op instance of the logging API whose methods do nothing and justreturn noOp().- Specified by:
atin classAbstractLogger<FluentLogger2.Api>
-
-