Interface Logger
-
public interface Logger
Allows StreamLink log messages to be written to the destination of your choice.
You obtain an instance of
caplin.streamlink.Logger
by callingstreamLinkInstance.getLogger()
on the StreamLink instance.StreamLinkJS only: When suitably configured (by adding
?debug=finer
to your url), StreamLink's log messages are automatically written to a dedicated window (the StreamLink Console). You would normally only enable this facility for debug purposes. You can call the Logger.log() method to write your own log messages to the StreamLink Console.You can use
caplin.streamlink.Logger
to write StreamLink's log messages to some other destination, such as a window that also contains log messages originating from your application. To do this, implement aLogListener
that receives the StreamLink messages and logs them to the required destination. Then obtain an instance ofLogger
, and call addListener() to attach yourLog Listener
to this instance. For a code example showing this, seeLogListener
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(LogListener listener, LogLevel level)
Adds aLogListener
to this Logger.void
log(LogLevel level, java.lang.String message, java.lang.Object... args)
Sends a log message to allLogListener
's that have been registered for this log level or above.void
removeListener(LogListener listener)
Removes aLogListener
that you previously added (seeaddListener
).
-
-
-
Method Detail
-
log
void log(LogLevel level, java.lang.String message, java.lang.Object... args)
Sends a log message to all
LogListener
's that have been registered for this log level or above.The
log()
method allows inline replacement of arguments. The arguments to replace these placeholders are then passed in at the end.Example :
logger.log(caplin.streamlink.LogLevel.Critical, "Error {0} has occurred with code {1}.", errorString, errorCode);
- Parameters:
level
- The logging level that will be associated with the logged message.message
- The message to log.args
- Arguments included in the log message.
-
addListener
void addListener(LogListener listener, LogLevel level)
Adds a
LogListener
to this Logger. The listener is called whenever a StreamLink message with the definedLogLevel
is to be logged.- Parameters:
listener
- The object that implements theLogListener
Interface.level
- TheLogLevel
of log messages for which thelistener
is to be called. Only messages at or above this log level will invoke thislistener
.
-
removeListener
void removeListener(LogListener listener)
Removes a
LogListener
that you previously added (seeaddListener
).- Parameters:
listener
- TheLogListener
you added.
-
-