FloggerLogSite

public abstract class FloggerLogSite implements LogSiteKey

A value type which representing the location of a single log statement. This class is similar to the StackTraceElement class but differs in one important respect.

A LogSite can be associated with a globally unique ID, which can identify a log statement more uniquely than a line number (it is possible to have multiple log statements appear to be on a single line, especially for obfuscated classes).

Log sites are intended to be injected into code automatically, typically via some form of bytecode rewriting. Each injection mechanism can have its own implementation of LogSite adapted to its needs.

As a fallback, for cases where no injection mechanism is configured, a log site based upon stack trace analysis is used. However, due to limitations in the information available from StackTraceElement, this log site will not be unique if multiple log statements are on the same, or if line number information was stripped from the class file.

See also

<a href="https://github.com/google/flogger/blob/cb9e836a897d36a78309ee8badf5cad4e6a2d3d8/api/src/main/java/com/google/common/flogger/LogSite.java">

Original Java code of Google Flogger

Constructors

Link copied to clipboard
public void FloggerLogSite()

Properties

Link copied to clipboard
public final static FloggerLogSite INVALID
An singleton LogSite instance used to indicate that valid log site information cannot be determined.
Link copied to clipboard
public final static int UNKNOWN_LINE
A value used for line numbers when the true information is not available.

Functions

Link copied to clipboard
public abstract String getClassName()
Returns the name of the class containing the log statement.
Link copied to clipboard
@Nullable()
public abstract @Nullable() String getFileName()
Returns the name of the class file containing the log statement (or null if not known).
Link copied to clipboard
public abstract int getLineNumber()
Returns a valid line number for the log statement in the range 1 - 65535, or UNKNOWN_LINE if not known.
Link copied to clipboard
public abstract String getMethodName()
Returns the name of the method containing the log statement.
Link copied to clipboard
public static FloggerLogSite injectedLogSite(String internalClassName, String methodName, int encodedLineNumber, @Nullable() @Nullable() String sourceFileName)
Creates a log site injected from constants held a class' constant pool.
Link copied to clipboard
public final String toString()