fm.liveswitch.LogProvider Class Referenceabstract

Base class for all logging provider implementations. More...

Public Member Functions

fm.liveswitch.IFunction1< fm.liveswitch.LogEvent, Boolean > getFilter ()
 Gets a filter on the log provider. More...
 
fm.liveswitch.LogLevel getLevel ()
 Gets the log level. More...
 
void log (fm.liveswitch.LogEvent logEvent)
 Log a message. More...
 
 LogProvider ()
 Initializes a new instance of the fm.liveswitch.LogProvider class using fm.liveswitch.Log#getDefaultLogLevel as the log level. More...
 
void setFilter (fm.liveswitch.IFunction1< fm.liveswitch.LogEvent, Boolean > value)
 Sets a filter on the log provider. More...
 
void setLevel (fm.liveswitch.LogLevel value)
 Sets the log level. More...
 

Static Public Member Functions

static String getLogLevelString (fm.liveswitch.LogLevel level)
 Converts a log-level to a 5-character string for consistently-spaced character sequences. More...
 
static String getPrefixTimestamp (java.util.Date timestamp)
 Converts a timestamp to an ISO-8601-formatted string for rendering in a log message (YYYY-MM-DDThh:mm:ss.sssZ). More...
 
static String getProduct ()
 Returns the name of the current product. More...
 

Protected Member Functions

abstract void doLog (fm.liveswitch.LogEvent logEvent)
 Logs a message at the specified log level. More...
 
String generateLogLine (fm.liveswitch.LogEvent logEvent)
 Generates a default log line. More...
 
String getPrefix (fm.liveswitch.LogLevel level, boolean includeTimestamp)
 Converts a log-level to a 5-character string for consistently-spaced character sequences. More...
 
int getProcessId ()
 Gets the current process id. More...
 

Detailed Description

Base class for all logging provider implementations.

Constructor & Destructor Documentation

◆ LogProvider()

fm.liveswitch.LogProvider.LogProvider ( )

Initializes a new instance of the fm.liveswitch.LogProvider class using fm.liveswitch.Log#getDefaultLogLevel as the log level.

Reimplemented in fm.liveswitch.java.LogProvider, and fm.liveswitch.android.LogProvider.

Member Function Documentation

◆ doLog()

abstract void fm.liveswitch.LogProvider.doLog ( fm.liveswitch.LogEvent  logEvent)
abstractprotected

Logs a message at the specified log level.

Parameters
logEventThe log event details.

Reimplemented in fm.liveswitch.TextLogProvider, fm.liveswitch.NullLogProvider, fm.liveswitch.LogStashLogProvider, and fm.liveswitch.LogEventLogProvider.

◆ generateLogLine()

String fm.liveswitch.LogProvider.generateLogLine ( fm.liveswitch.LogEvent  logEvent)
protected

Generates a default log line.

Parameters
logEventThe log event details.

◆ getFilter()

fm.liveswitch.IFunction1<fm.liveswitch.LogEvent,Boolean> fm.liveswitch.LogProvider.getFilter ( )

Gets a filter on the log provider.

Returning

true

will log the event, while returning

false

will skip it.

◆ getLevel()

fm.liveswitch.LogLevel fm.liveswitch.LogProvider.getLevel ( )

Gets the log level.

◆ getLogLevelString()

static String fm.liveswitch.LogProvider.getLogLevelString ( fm.liveswitch.LogLevel  level)
static

Converts a log-level to a 5-character string for consistently-spaced character sequences.

Parameters
levelThe log level.
Returns
The log level as an upper-case string with right-side whitespace padding to ensure a 5-character sequence.

◆ getPrefix()

String fm.liveswitch.LogProvider.getPrefix ( fm.liveswitch.LogLevel  level,
boolean  includeTimestamp 
)
protected

Converts a log-level to a 5-character string for consistently-spaced character sequences.

Parameters
levelThe log level.
includeTimestampWhether to include a timestamp in the prefix.
Returns
The log level as an upper-case string with right-side whitespace padding to ensure a 5-character sequence.

◆ getPrefixTimestamp()

static String fm.liveswitch.LogProvider.getPrefixTimestamp ( java.util.Date  timestamp)
static

Converts a timestamp to an ISO-8601-formatted string for rendering in a log message (YYYY-MM-DDThh:mm:ss.sssZ).

Parameters
timestampThe timestamp.
Returns
The timestamp as a formatted string.

◆ getProcessId()

int fm.liveswitch.LogProvider.getProcessId ( )
protected

Gets the current process id.

◆ getProduct()

static String fm.liveswitch.LogProvider.getProduct ( )
static

Returns the name of the current product.

◆ log()

void fm.liveswitch.LogProvider.log ( fm.liveswitch.LogEvent  logEvent)

Log a message.

Parameters
logEventThe log event details.

◆ setFilter()

void fm.liveswitch.LogProvider.setFilter ( fm.liveswitch.IFunction1< fm.liveswitch.LogEvent, Boolean >  value)

Sets a filter on the log provider.

Returning

true

will log the event, while returning

false

will skip it.

◆ setLevel()

void fm.liveswitch.LogProvider.setLevel ( fm.liveswitch.LogLevel  value)

Sets the log level.