Class LogMessageFormatter
- java.lang.Object
-
- com.google.common.flogger.backend.LogMessageFormatter
-
public abstract class LogMessageFormatter extends Object
API for formatting Flogger log messages from logData and scoped metadata.This API is not used directly in the core Flogger libraries yet, but will become part of the log message formatting API eventually. For now it should be considered an implementation detail and definitely unstable.
-
-
Constructor Summary
Constructors Constructor Description LogMessageFormatter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract StringBuilderappend(LogData logData, MetadataProcessor metadata, StringBuilder buffer)Formats the log message and metadata into the given buffer.Stringformat(LogData logData, MetadataProcessor metadata)Returns a formatted representation of the log message and metadata.
-
-
-
Method Detail
-
format
public String format(LogData logData, MetadataProcessor metadata)
Returns a formatted representation of the log message and metadata. Currently this class is only responsible for formatting the main body of the log message and not thing like log site, timestamps or thread information.By default this method just returns:
append(logData, metadata, new StringBuilder()).toString()Formatter implementations may be able to implement it more efficiently (e.g. if they can safely detect when no formatting is required). See also the helper methods in
SimpleMessageFormatter.
-
append
@CanIgnoreReturnValue public abstract StringBuilder append(LogData logData, MetadataProcessor metadata, StringBuilder buffer)
Formats the log message and metadata into the given buffer. Currently this class is only responsible for formatting the main body of the log message and not thing like log site, timestamps or thread information.- Returns:
- the given buffer for method chaining.
-
-