org.eclipse.paho.client.mqttv3.logging
Class JSR47Logger

java.lang.Object
  extended by org.eclipse.paho.client.mqttv3.logging.JSR47Logger
All Implemented Interfaces:
Logger

public class JSR47Logger
extends Object
implements Logger

Implementation of the the logger interface that uses java.uti.logging A Logger that utilises Java's built in logging facility - java.util.logging.

A sample java.util.logging properties file - jsr47min.properties is provided that demonstrates how to run with a memory based trace facility that runs with minimal performance overhead. The memory buffer can be dumped when a log/trace record is written matching the MemoryHandlers trigger level or when the push method is invoked on the MemoryHandler. Debug provides method to make it easy to dump the memory buffer as well as other useful debug info.


Field Summary
 
Fields inherited from interface org.eclipse.paho.client.mqttv3.logging.Logger
CONFIG, FINE, FINER, FINEST, INFO, SEVERE, WARNING
 
Constructor Summary
JSR47Logger()
           
 
Method Summary
 void config(String sourceClass, String sourceMethod, String msg)
          Log a message, specifying source class and method, if the logger is currently enabled for the given message level.
 void config(String sourceClass, String sourceMethod, String msg, Object[] inserts)
          Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.
 void config(String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable thrown)
          Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.
protected static void dumpMemoryTrace47(Logger logger)
           
 void dumpTrace()
           
 void fine(String sourceClass, String sourceMethod, String msg)
          Trace a message, specifying source class and method, if the logger is currently enabled for the given message level.
 void fine(String sourceClass, String sourceMethod, String msg, Object[] inserts)
          Trace a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.
 void fine(String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable ex)
           
 void finer(String sourceClass, String sourceMethod, String msg)
          Trace a message, specifying source class and method, if the logger is currently enabled for the given message level.
 void finer(String sourceClass, String sourceMethod, String msg, Object[] inserts)
          Trace a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.
 void finer(String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable ex)
           
 void finest(String sourceClass, String sourceMethod, String msg)
          Trace a message, specifying source class and method, if the logger is currently enabled for the given message level.
 void finest(String sourceClass, String sourceMethod, String msg, Object[] inserts)
          Trace a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.
 void finest(String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable ex)
           
 String formatMessage(String msg, Object[] inserts)
          Format a log message without causing it to be written to the log.
 void info(String sourceClass, String sourceMethod, String msg)
          Log a message, specifying source class and method, if the logger is currently enabled for the given message level.
 void info(String sourceClass, String sourceMethod, String msg, Object[] inserts)
          Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.
 void info(String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable thrown)
          Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.
 void initialise(ResourceBundle logMsgCatalog, String loggerID, String resourceContext)
           
 boolean isLoggable(int level)
          Check if a message of the given level would actually be logged by this logger.
 void log(int level, String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable thrown)
          Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.
 void setResourceName(String logContext)
          Set a name that can be used to provide context with each log record.
 void severe(String sourceClass, String sourceMethod, String msg)
          Log a message, specifying source class and method, if the logger is currently enabled for the given message level.
 void severe(String sourceClass, String sourceMethod, String msg, Object[] inserts)
          Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.
 void severe(String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable thrown)
          Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.
 void trace(int level, String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable ex)
          Log a trace message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.
 void warning(String sourceClass, String sourceMethod, String msg)
          Log a message, specifying source class and method, if the logger is currently enabled for the given message level.
 void warning(String sourceClass, String sourceMethod, String msg, Object[] inserts)
          Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.
 void warning(String sourceClass, String sourceMethod, String msg, Object[] inserts, Throwable thrown)
          Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSR47Logger

public JSR47Logger()
Method Detail

initialise

public void initialise(ResourceBundle logMsgCatalog,
                       String loggerID,
                       String resourceContext)
Specified by:
initialise in interface Logger
Parameters:
logMsgCatalog - The resource bundle associated with this logger
loggerID - The suffix for the loggerName (will be appeneded to org.eclipse.paho.client.mqttv3
resourceContext - A context for the logger e.g. clientID or appName...

setResourceName

public void setResourceName(String logContext)
Description copied from interface: Logger
Set a name that can be used to provide context with each log record. This overrides the value passed in on initialise

Specified by:
setResourceName in interface Logger

isLoggable

public boolean isLoggable(int level)
Description copied from interface: Logger
Check if a message of the given level would actually be logged by this logger. This check is based on the Loggers effective level, which may be inherited from its parent.

Specified by:
isLoggable in interface Logger
Parameters:
level - a message logging level.
Returns:
true if the given message level is currently being logged.

severe

public void severe(String sourceClass,
                   String sourceMethod,
                   String msg)
Description copied from interface: Logger
Log a message, specifying source class and method, if the logger is currently enabled for the given message level.

Specified by:
severe in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used.

severe

public void severe(String sourceClass,
                   String sourceMethod,
                   String msg,
                   Object[] inserts)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.

Specified by:
severe in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.

severe

public void severe(String sourceClass,
                   String sourceMethod,
                   String msg,
                   Object[] inserts,
                   Throwable thrown)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.

Specified by:
severe in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.
thrown - Throwable associated with log message.

warning

public void warning(String sourceClass,
                    String sourceMethod,
                    String msg)
Description copied from interface: Logger
Log a message, specifying source class and method, if the logger is currently enabled for the given message level.

Specified by:
warning in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used.

warning

public void warning(String sourceClass,
                    String sourceMethod,
                    String msg,
                    Object[] inserts)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.

Specified by:
warning in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.

warning

public void warning(String sourceClass,
                    String sourceMethod,
                    String msg,
                    Object[] inserts,
                    Throwable thrown)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.

Specified by:
warning in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.
thrown - Throwable associated with log message.

info

public void info(String sourceClass,
                 String sourceMethod,
                 String msg)
Description copied from interface: Logger
Log a message, specifying source class and method, if the logger is currently enabled for the given message level.

Specified by:
info in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used.

info

public void info(String sourceClass,
                 String sourceMethod,
                 String msg,
                 Object[] inserts)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.

Specified by:
info in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.

info

public void info(String sourceClass,
                 String sourceMethod,
                 String msg,
                 Object[] inserts,
                 Throwable thrown)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.

Specified by:
info in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.
thrown - Throwable associated with log message.

config

public void config(String sourceClass,
                   String sourceMethod,
                   String msg)
Description copied from interface: Logger
Log a message, specifying source class and method, if the logger is currently enabled for the given message level.

Specified by:
config in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used.

config

public void config(String sourceClass,
                   String sourceMethod,
                   String msg,
                   Object[] inserts)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.

Specified by:
config in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.

config

public void config(String sourceClass,
                   String sourceMethod,
                   String msg,
                   Object[] inserts,
                   Throwable thrown)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.

Specified by:
config in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.
thrown - Throwable associated with log message.

log

public void log(int level,
                String sourceClass,
                String sourceMethod,
                String msg,
                Object[] inserts,
                Throwable thrown)
Description copied from interface: Logger
Log a message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.

Specified by:
log in interface Logger
Parameters:
level - One of the message level identifiers, e.g. SEVERE.
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message, may be null.
thrown - Throwable associated with log message.

fine

public void fine(String sourceClass,
                 String sourceMethod,
                 String msg)
Description copied from interface: Logger
Trace a message, specifying source class and method, if the logger is currently enabled for the given message level.

Specified by:
fine in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the value. Otherwise the original msg string is used.

fine

public void fine(String sourceClass,
                 String sourceMethod,
                 String msg,
                 Object[] inserts)
Description copied from interface: Logger
Trace a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.

Specified by:
fine in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.

fine

public void fine(String sourceClass,
                 String sourceMethod,
                 String msg,
                 Object[] inserts,
                 Throwable ex)
Specified by:
fine in interface Logger

finer

public void finer(String sourceClass,
                  String sourceMethod,
                  String msg)
Description copied from interface: Logger
Trace a message, specifying source class and method, if the logger is currently enabled for the given message level.

Specified by:
finer in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the value. Otherwise the original msg string is used.

finer

public void finer(String sourceClass,
                  String sourceMethod,
                  String msg,
                  Object[] inserts)
Description copied from interface: Logger
Trace a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.

Specified by:
finer in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.

finer

public void finer(String sourceClass,
                  String sourceMethod,
                  String msg,
                  Object[] inserts,
                  Throwable ex)
Specified by:
finer in interface Logger

finest

public void finest(String sourceClass,
                   String sourceMethod,
                   String msg)
Description copied from interface: Logger
Trace a message, specifying source class and method, if the logger is currently enabled for the given message level.

Specified by:
finest in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the value. Otherwise the original msg string is used.

finest

public void finest(String sourceClass,
                   String sourceMethod,
                   String msg,
                   Object[] inserts)
Description copied from interface: Logger
Trace a message, specifying source class and method, with an array of object arguments, if the logger is currently enabled for the given message level.

Specified by:
finest in interface Logger
Parameters:
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.

finest

public void finest(String sourceClass,
                   String sourceMethod,
                   String msg,
                   Object[] inserts,
                   Throwable ex)
Specified by:
finest in interface Logger

trace

public void trace(int level,
                  String sourceClass,
                  String sourceMethod,
                  String msg,
                  Object[] inserts,
                  Throwable ex)
Description copied from interface: Logger
Log a trace message, specifying source class and method, with an array of object arguments and a throwable, if the logger is currently enabled for the given message level.

Specified by:
trace in interface Logger
Parameters:
level - One of the message level identifiers, e.g. SEVERE.
sourceClass - Name of class that issued the logging request.
sourceMethod - Name of method that issued the logging request.
msg - The key in the message catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message, may be null.

formatMessage

public String formatMessage(String msg,
                            Object[] inserts)
Description copied from interface: Logger
Format a log message without causing it to be written to the log.

Specified by:
formatMessage in interface Logger
Parameters:
msg - The key in the message localization catalog for the message or the actual message itself. During formatting, if the logger has a mapping for the msg string, then the msg string is replaced by the localized value. Otherwise the original msg string is used. The formatter uses java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two inserts into the message.
inserts - Array of parameters to the message.
Returns:
The formatted message for the current locale.

dumpTrace

public void dumpTrace()
Specified by:
dumpTrace in interface Logger

dumpMemoryTrace47

protected static void dumpMemoryTrace47(Logger logger)


Copyright © 2013. All Rights Reserved.