Package com.spotify.logging
Class LoggingSupport
- java.lang.Object
-
- com.spotify.logging.LoggingSupport
-
public class LoggingSupport extends Object
Utility for emitting log messages in the Spotify log format.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LoggingSupport.Ident
The ident portion of the log line (comes between the record ID and the log message type).
-
Field Summary
Fields Modifier and Type Field Description protected static AtomicLong
rid
-
Constructor Summary
Constructors Constructor Description LoggingSupport()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static void
appendEscaped(Object o, StringBuilder out)
protected static String
buildLogLine(String type, int version, LoggingSupport.Ident ident, Object... args)
static void
debug(org.slf4j.Logger logger, String type, int version, LoggingSupport.Ident ident, Object... args)
Generate a new debug log message according to the Spotify log format.static void
error(org.slf4j.Logger logger, String type, int version, LoggingSupport.Ident ident, Object... args)
Generate a new error log message according to the Spotify log format.static void
info(org.slf4j.Logger logger, String type, int version, LoggingSupport.Ident ident, Object... args)
Generate a new info log message according to the Spotify log format.static void
warn(org.slf4j.Logger logger, String type, int version, LoggingSupport.Ident ident, Object... args)
Generate a new warn log message according to the Spotify log format.
-
-
-
Field Detail
-
rid
protected static final AtomicLong rid
-
-
Method Detail
-
debug
public static void debug(org.slf4j.Logger logger, String type, int version, @Nullable LoggingSupport.Ident ident, Object... args)
Generate a new debug log message according to the Spotify log format.- Parameters:
logger
- Which Logger to use for writing the log messages. It is assumed that this Logger is already set up via com.spotify.logging.LoggingConfigurator and a [service]-log4j.xml configuration so that the time stamp, hostname, service, and process ID portions of the log message are automatically prepended.type
- Log message type. Log messages are defined in the messages.py module in the log-parser git project. When a new message type is added or changed in a service, it should also be changed/added in messages.py.version
- Version of the log message. This is incremented by callers and in messages.py if the format of a given log message type is changed.ident
- Ident object to give information generally about a client who made the request that resulted in this message.args
- Additional arguments that will be converted to strings, escaped, and appended (tab-separated) after the log message type and version number.
-
info
public static void info(org.slf4j.Logger logger, String type, int version, @Nullable LoggingSupport.Ident ident, Object... args)
Generate a new info log message according to the Spotify log format.- See Also:
for parameter descriptions.
-
warn
public static void warn(org.slf4j.Logger logger, String type, int version, @Nullable LoggingSupport.Ident ident, Object... args)
Generate a new warn log message according to the Spotify log format.- See Also:
for parameter descriptions.
-
error
public static void error(org.slf4j.Logger logger, String type, int version, @Nullable LoggingSupport.Ident ident, Object... args)
Generate a new error log message according to the Spotify log format.- See Also:
for parameter descriptions.
-
buildLogLine
protected static String buildLogLine(String type, int version, @Nullable LoggingSupport.Ident ident, Object... args)
-
appendEscaped
protected static void appendEscaped(@Nullable Object o, StringBuilder out)
-
-