Class LoggerChannelImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.logging.LoggerChannelImpl
-
- All Implemented Interfaces:
LoggerChannel
public class LoggerChannelImpl extends java.lang.Object implements LoggerChannel
-
-
Field Summary
Fields Modifier and Type Field Description private AEDiagnosticsLogger
diagnostic_logger
(package private) java.util.List
listeners
private Logger
logger
private static LogIDs
LOGID
private java.lang.String
name
(package private) boolean
no_output
private boolean
timestamp
-
Fields inherited from interface com.biglybt.pif.logging.LoggerChannel
LT_ERROR, LT_INFORMATION, LT_WARNING
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LoggerChannelImpl(Logger _logger, java.lang.String _name, boolean _timestamp, boolean _no_output)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(LoggerChannelListener l)
Add a LoggerChannelListener to this LoggerChannelprotected java.lang.String
addTimeStamp(java.lang.String data)
private static java.lang.String
format(int n)
java.io.File
getCurrentFile(boolean flush)
retrieves the current file associated with the channel, null if noneboolean
getForce()
Logger
getLogger()
Retrieve the parent Logger object for this LoggerChannel.java.lang.String
getName()
Returns the name of the Logger Channelprotected java.lang.String
getTimeStamp()
boolean
isEnabled()
Indicates whether or not logging is enabled - use to optimise calls to the log methods that require resources to construct the message to be logged.void
log(int log_type, java.lang.String data)
Log a message of a specific type to this channel's loggervoid
log(java.lang.Object[] relatedTo, int log_type, java.lang.String data)
Log a string against a list of objectsvoid
log(java.lang.Object[] relatedTo, java.lang.String data)
Log an error against a list of objects with implicit typeLoggerChannel.LT_INFORMATION
void
log(java.lang.Object[] relatedTo, java.lang.String str, java.lang.Throwable error)
Log an error against a list of objectsvoid
log(java.lang.Object relatedTo, int log_type, java.lang.String data)
Log an error against an object.void
log(java.lang.Object relatedTo, java.lang.String data)
Log an error against an object with implicit typeLoggerChannel.LT_INFORMATION
void
log(java.lang.Object relatedTo, java.lang.String str, java.lang.Throwable error)
Log an error against an object.void
log(java.lang.String data)
log text with implicit typeLoggerChannel.LT_INFORMATION
void
log(java.lang.String str, java.lang.Throwable error)
log an error with implicit type ofLoggerChannel.LT_ERROR
void
log(java.lang.Throwable error)
log an error with implicit type ofLoggerChannel.LT_ERROR
void
logAlert(int alert_type, java.lang.String message)
raise an alert to the user, if UI present Note that messages shown to the user are filtered on unique message content So if you raise an identical alert the second + subsequent messages will not be shown.protected void
logAlert(int alert_type, java.lang.String message, boolean repeatable)
void
logAlert(java.lang.String message, java.lang.Throwable e)
Alert the user of an errorvoid
logAlertRepeatable(int alert_type, java.lang.String message)
Raise an alert to the user, if UI present.void
logAlertRepeatable(java.lang.String message, java.lang.Throwable e)
Raise an alert to the user, if UI present.private int
LogTypePluginToCore(int pluginLogType)
private void
notifyListeners(int log_type, java.lang.String data)
private void
notifyListeners(java.lang.String listenersText, java.lang.Throwable error)
void
removeListener(LoggerChannelListener l)
Remove a reviously added LoggerChannelListenervoid
setDiagnostic()
This causes the channel to also write to logs/name files in a cyclic fashion (c.f.void
setDiagnostic(long max_file_size, boolean diag_timestamp)
void
setForce(boolean forceToFile)
logging to file is disabled by default in non-beta builds.
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
logger
private final Logger logger
-
name
private final java.lang.String name
-
timestamp
private final boolean timestamp
-
no_output
final boolean no_output
-
listeners
final java.util.List listeners
-
diagnostic_logger
private AEDiagnosticsLogger diagnostic_logger
-
-
Constructor Detail
-
LoggerChannelImpl
protected LoggerChannelImpl(Logger _logger, java.lang.String _name, boolean _timestamp, boolean _no_output)
-
-
Method Detail
-
getLogger
public Logger getLogger()
Description copied from interface:LoggerChannel
Retrieve the parent Logger object for this LoggerChannel.- Specified by:
getLogger
in interfaceLoggerChannel
- Returns:
- Logger object
-
getName
public java.lang.String getName()
Description copied from interface:LoggerChannel
Returns the name of the Logger Channel- Specified by:
getName
in interfaceLoggerChannel
- Returns:
- Logger channel name
-
isEnabled
public boolean isEnabled()
Description copied from interface:LoggerChannel
Indicates whether or not logging is enabled - use to optimise calls to the log methods that require resources to construct the message to be logged. Note that this doesn't apply to alerts - these will always be handled- Specified by:
isEnabled
in interfaceLoggerChannel
- Returns:
- Enabled state of logging
-
setDiagnostic
public void setDiagnostic()
Description copied from interface:LoggerChannel
This causes the channel to also write to logs/name files in a cyclic fashion (c.f. the debug_1/2._log files)- Specified by:
setDiagnostic
in interfaceLoggerChannel
-
setForce
public void setForce(boolean forceToFile)
Description copied from interface:LoggerChannel
logging to file is disabled by default in non-beta builds. This forces writing to file regardless- Specified by:
setForce
in interfaceLoggerChannel
-
getForce
public boolean getForce()
- Specified by:
getForce
in interfaceLoggerChannel
- Returns:
-
getCurrentFile
public java.io.File getCurrentFile(boolean flush)
Description copied from interface:LoggerChannel
retrieves the current file associated with the channel, null if none- Specified by:
getCurrentFile
in interfaceLoggerChannel
- Returns:
-
setDiagnostic
public void setDiagnostic(long max_file_size, boolean diag_timestamp)
- Specified by:
setDiagnostic
in interfaceLoggerChannel
-
LogTypePluginToCore
private int LogTypePluginToCore(int pluginLogType)
-
notifyListeners
private void notifyListeners(int log_type, java.lang.String data)
-
notifyListeners
private void notifyListeners(java.lang.String listenersText, java.lang.Throwable error)
-
log
public void log(int log_type, java.lang.String data)
Description copied from interface:LoggerChannel
Log a message of a specific type to this channel's logger- Specified by:
log
in interfaceLoggerChannel
- Parameters:
log_type
- LT_* constantdata
- text to log
-
log
public void log(java.lang.String data)
Description copied from interface:LoggerChannel
log text with implicit typeLoggerChannel.LT_INFORMATION
- Specified by:
log
in interfaceLoggerChannel
- Parameters:
data
- text to log
-
log
public void log(java.lang.Object[] relatedTo, int log_type, java.lang.String data)
Description copied from interface:LoggerChannel
Log a string against a list of objects- Specified by:
log
in interfaceLoggerChannel
- Parameters:
relatedTo
- a list of what this log is related to (ex. Peer, Torrent, Download, Object)log_type
- LT_* constantdata
- text to log
-
log
public void log(java.lang.Object relatedTo, int log_type, java.lang.String data)
Description copied from interface:LoggerChannel
Log an error against an object.- Specified by:
log
in interfaceLoggerChannel
- Parameters:
relatedTo
- What this log is related to (ex. Peer, Torrent, Download, Object, etc)log_type
- LT_* constantdata
- text to log
-
log
public void log(java.lang.Throwable error)
Description copied from interface:LoggerChannel
log an error with implicit type ofLoggerChannel.LT_ERROR
- Specified by:
log
in interfaceLoggerChannel
- Parameters:
error
- Throwable object to log
-
log
public void log(java.lang.String str, java.lang.Throwable error)
Description copied from interface:LoggerChannel
log an error with implicit type ofLoggerChannel.LT_ERROR
- Specified by:
log
in interfaceLoggerChannel
- Parameters:
str
- text to logerror
- Throwable object to log
-
log
public void log(java.lang.Object[] relatedTo, java.lang.String str, java.lang.Throwable error)
Description copied from interface:LoggerChannel
Log an error against a list of objects- Specified by:
log
in interfaceLoggerChannel
- Parameters:
relatedTo
- a list of what this log is related to (ex. Peer, Torrent, Download, Object)str
- text to logerror
- Error that will be appended to the log entry
-
log
public void log(java.lang.Object relatedTo, java.lang.String str, java.lang.Throwable error)
Description copied from interface:LoggerChannel
Log an error against an object.- Specified by:
log
in interfaceLoggerChannel
- Parameters:
relatedTo
- What this log is related to (ex. Peer, Torrent, Download, Object, etc)str
- text to logerror
- Error that will be appended to the log entry
-
log
public void log(java.lang.Object[] relatedTo, java.lang.String data)
Description copied from interface:LoggerChannel
Log an error against a list of objects with implicit typeLoggerChannel.LT_INFORMATION
- Specified by:
log
in interfaceLoggerChannel
- Parameters:
relatedTo
- a list of what this log is related to (ex. Peer, Torrent, Download, Object)data
- text to log
-
log
public void log(java.lang.Object relatedTo, java.lang.String data)
Description copied from interface:LoggerChannel
Log an error against an object with implicit typeLoggerChannel.LT_INFORMATION
- Specified by:
log
in interfaceLoggerChannel
- Parameters:
relatedTo
- What this log is related to (ex. Peer, Torrent, Download, Object, etc)data
- text to log
-
logAlert
protected void logAlert(int alert_type, java.lang.String message, boolean repeatable)
-
logAlert
public void logAlert(int alert_type, java.lang.String message)
Description copied from interface:LoggerChannel
raise an alert to the user, if UI present Note that messages shown to the user are filtered on unique message content So if you raise an identical alert the second + subsequent messages will not be shown. Thus, if you want "identical" messages to be shown, prefix them with something unique like a timestamp.- Specified by:
logAlert
in interfaceLoggerChannel
- Parameters:
alert_type
- LT_* constantmessage
- text to alert user with
-
logAlertRepeatable
public void logAlertRepeatable(int alert_type, java.lang.String message)
Description copied from interface:LoggerChannel
Raise an alert to the user, if UI present. Subsequent, identical messages will always generate an alert (i.e. duplicates won't be filtered)- Specified by:
logAlertRepeatable
in interfaceLoggerChannel
- Parameters:
alert_type
- LT_* constantmessage
- text to alert user with
-
logAlert
public void logAlert(java.lang.String message, java.lang.Throwable e)
Description copied from interface:LoggerChannel
Alert the user of an error- Specified by:
logAlert
in interfaceLoggerChannel
- Parameters:
message
- text to alert user withe
- Error that will be attached to the alert
-
logAlertRepeatable
public void logAlertRepeatable(java.lang.String message, java.lang.Throwable e)
Description copied from interface:LoggerChannel
Raise an alert to the user, if UI present. Subsequent, identical messages will always generate an alert (i.e. duplicates won't be filtered)- Specified by:
logAlertRepeatable
in interfaceLoggerChannel
- Parameters:
message
- text to alert user withe
- Error that will be attached to the alert
-
addListener
public void addListener(LoggerChannelListener l)
Description copied from interface:LoggerChannel
Add a LoggerChannelListener to this LoggerChannel- Specified by:
addListener
in interfaceLoggerChannel
- Parameters:
l
- Listener to add
-
removeListener
public void removeListener(LoggerChannelListener l)
Description copied from interface:LoggerChannel
Remove a reviously added LoggerChannelListener- Specified by:
removeListener
in interfaceLoggerChannel
- Parameters:
l
- Listener to remove.
-
addTimeStamp
protected java.lang.String addTimeStamp(java.lang.String data)
-
getTimeStamp
protected java.lang.String getTimeStamp()
-
format
private static java.lang.String format(int n)
-
-