java.lang.Object
esa.opensf.osfi.Logger
Logger.
Manages the log messages raised.
Manages the log messages raised.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classProvides an implementation ofSystem.LoggerFinder. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidShows a formatted debug message, if the environment variable "DEBUG_MODE" is equal to "On".static voidShows a formatted error message.static voidfinishExecution(int errorCode) Shows an information message and exits the program execution with an specific error code.static voidShows a formatted information message.static booleanOSFI writes log banners in colour if theOSFI_LOG_COLORenvironment variable is set to "On".static booleanOSFI only writes messages with the "Debug" category to the actual log if theDEBUG_MODEenvironment variable is set to "On".static voidprintMessage(String logType, String message, String fg, String bg) Deprecated.Internal function, to be removed from public APIstatic voidprogress(int step, int nSteps) Shows a formatted progress message.static voidqualityReport(String name, double value) Shows a formatted message reporting a quality indicator.static voidqualityReport(String name, String value) Shows a formatted message reporting a quality indicator.static System.LoggerEquivalent to callingsysLoggerToOsfiLog(String)with a null context.static System.LoggersysLoggerToOsfiLog(String context) Equivalent to callingsysLoggerToOsfiLog(String, java.lang.System.Logger.Level)with the minimum level given byLogger.SysLoggerFinder.getMinLevel().static System.LoggersysLoggerToOsfiLog(String context, System.Logger.Level minLvl) Creates a JDK logger implementation that sends any resulting messages to the OSFI log, by matching the log levels as follows: Any call with a level less severe than minLvl is ignored/dropped.static voidShows a formatted warning message.
-
Method Details
-
isDebugging
public static boolean isDebugging()OSFI only writes messages with the "Debug" category to the actual log if theDEBUG_MODEenvironment variable is set to "On". Note that the environment variable is only checked the first time this is called.- Returns:
- true if the system writes debug messages to the log, false otherwise.
-
isColored
public static boolean isColored()OSFI writes log banners in colour if theOSFI_LOG_COLORenvironment variable is set to "On". In that case, the colours used are:- Error: Red
- Warning: Yellow
- Progress: Cyan
- Info: Green
- Returns:
- true if the system writes coloured log banners, false otherwise.
-
error
Shows a formatted error message.- Parameters:
message- - text of the message
-
warning
Shows a formatted warning message.- Parameters:
message- - text of the message
-
info
Shows a formatted information message.- Parameters:
message- - text of the message
-
debug
Shows a formatted debug message, if the environment variable "DEBUG_MODE" is equal to "On". First time this function is called, checks the declaration of that variable. If it is not declared, presents a warning message and assumes it as "Off".- Parameters:
message- - text of the message
-
progress
public static void progress(int step, int nSteps) Shows a formatted progress message.- Parameters:
step- - current step numbernSteps- - maximum number of steps.
-
finishExecution
public static void finishExecution(int errorCode) Shows an information message and exits the program execution with an specific error code.- Parameters:
errorCode- - Code of error to exit with.
-
qualityReport
Shows a formatted message reporting a quality indicator.- Parameters:
name- - Name of the quality indicatorvalue- - Double associated to the quality indicator pointed by name
-
qualityReport
Shows a formatted message reporting a quality indicator.- Parameters:
name- - Name of the quality indicatorvalue- - String associated to the quality indicator pointed by name
-
printMessage
@Deprecated(since="3.8.0") public static void printMessage(String logType, String message, String fg, String bg) Deprecated.Internal function, to be removed from public APIShows a formatted information message of the given log type.- Parameters:
logType- Banner to be used before the first separator.message- Text after the first separator.fg- Colour code for the foreground, seeVt100.bg- Colour code for the brackgronund, seeVt100.
-
sysLoggerToOsfiLog
Equivalent to callingsysLoggerToOsfiLog(String)with a null context.- Returns:
- JDK logger that forwards messages to the other methods in this class.
-
sysLoggerToOsfiLog
Equivalent to callingsysLoggerToOsfiLog(String, java.lang.System.Logger.Level)with the minimum level given byLogger.SysLoggerFinder.getMinLevel().- Parameters:
context- Used to prefix log messages, or null.- Returns:
- JDK logger that forwards messages to the other methods in this class.
-
sysLoggerToOsfiLog
Creates a JDK logger implementation that sends any resulting messages to the OSFI log, by matching the log levels as follows:- Any call with a level less severe than minLvl is ignored/dropped.
ERRORor higher is sent toerror(String).WARNINGor higher is sent towarning(String).INFOor higher is sent toinfo(String).- Any other value below INFO is sent to
debug(String), where it may be dropped or written,depending on the status ofisDebugging().
nameis equal to context, or "OSFI" if null.- Parameters:
context- Used to prefix log messages, or null.minLvl- Messages with a level less severe than this will be ignored.- Returns:
- JDK logger that forwards messages to the other methods in this class.
-