Package org.kiwiproject.jsch
Class JSchSlf4jLogger
java.lang.Object
org.kiwiproject.jsch.JSchSlf4jLogger
- All Implemented Interfaces:
com.jcraft.jsch.Logger
Custom logger implementing Jsch's
Logger class.
Some implementation notes:
- JSch's INFO level logging is very verbose, so we are treating it like DEBUG level
- Jsch has both ERROR and FATAL levels, but SLF4J only has ERROR, so we treat both as ERROR in SLF4J
-
Field Summary
Fields inherited from interface com.jcraft.jsch.Logger
DEBUG, ERROR, FATAL, INFO, WARN -
Constructor Summary
ConstructorsConstructorDescriptionConstruct an instance with a default logger, e.g. fororg.kiwiproject.jsch.JSchSlf4jLogger.JSchSlf4jLogger(org.slf4j.Logger slf4jLogger) Construct an instance using the given SLF4J logger. -
Method Summary
-
Constructor Details
-
JSchSlf4jLogger
public JSchSlf4jLogger()Construct an instance with a default logger, e.g. fororg.kiwiproject.jsch.JSchSlf4jLogger.Usually you should use
JSchSlf4jLogger(Logger)in order to specify the SLF4JLoggerexplicitly to control the logging level and logger name. -
JSchSlf4jLogger
public JSchSlf4jLogger(org.slf4j.Logger slf4jLogger) Construct an instance using the given SLF4J logger.- Parameters:
slf4jLogger- the SLF4JLoggerthat will be the destination for JSch logging output.
-
-
Method Details
-
isEnabled
public boolean isEnabled(int level) Is the given level enabled?- Specified by:
isEnabledin interfacecom.jcraft.jsch.Logger- Parameters:
level- one of the public constants inLogger- Returns:
- true if the level is enabled in the underlying SLF4J logger.
-
log
Log the given message at the given level.If provided an invalid level, a message will be logged about the invalid level, along with the given message, at the SLF4J ERROR level. This is intended to provide both information about the problem and provide the original message, rather than throwing an exception or suppressing the message.
- Specified by:
login interfacecom.jcraft.jsch.Logger- Parameters:
level- one of the public constants inLoggermessage- the message to log
-