Package com.pnfsoftware.jeb.util.logging
Class StructuredLogger
java.lang.Object
com.pnfsoftware.jeb.util.logging.StructuredLogger
- All Implemented Interfaces:
ILogger
The structured logger can generate HTML formatted log.
-
Constructor Summary
ConstructorsConstructorDescriptionStructuredLogger(String name) Create a structured logger with structured and regular logging enabled.StructuredLogger(String name, boolean slEnabled, boolean rlEnabled) Create a structured logger. -
Method Summary
Modifier and TypeMethodDescriptionvoidbeginSection(String name) Start a closed structured log section.voidbeginSection(String name, boolean defaultOpen) Start a structured log section.voidLog an exception's stack trace.voidLog an exception's stack trace, prefixed by an optional message.voidLog an exception's stack trace, prefixed by an optional message.voidLog an exception at the debug level.voidClose the current structured log section.voidLog a debug message.voidLog an error message.voidAlias fortrace().Generate an HTML representation of the structured log.voidgenerateHtml(FileOutputStream out, Charset charset) Same as generateHtml but per blocks.intRetrieve the cut-off level for that logger.getName()Get the logger name.booleanDetermine whether structured entries have been recorded.voidLog an internal message with an explicit structured display importance.voidReserved for internal logging.voidiBreak()Insert one visual break in the structured log.voidiBreak(int cnt) Insert visual breaks in the structured log.voidLog an internal highlighted message.voidLog an internal section-level highlighted message.voidLog an internal subtitle-level highlighted message.voidLog an internal title-level highlighted message.voidLog an internal chapter-level highlighted message.voidLog an internal low-importance message.voidLog an information message.voidInsert a visual separator in the structured log.booleanDetermine whether regular logging is enabled.booleanDetermine whether structured logging is enabled.voidLog a string message.voidLog a structured message with an explicit display importance.voidsetEnabledLevel(int level) Set the cut-off level for a logger.voidSet the logger name.voidAlias forerror().voidLog a transient status message (STATUS).voidLog a trace message.voidLog a warning message.voidAlias forwarn().
-
Constructor Details
-
StructuredLogger
Create a structured logger with structured and regular logging enabled.- Parameters:
name- the logger's name
-
StructuredLogger
Create a structured logger.- Parameters:
name- the logger's nameslEnabled- true to enable structured logging; when logging is complete, the structured log may be dumped to HTML using aStructuredLoggerHtmlGeneratorrlEnabled- true to enable regular logging (eg, to console) as well
-
-
Method Details
-
isStructuredLoggingEnabled
public boolean isStructuredLoggingEnabled()Determine whether structured logging is enabled.- Returns:
- true if structured entries are recorded
-
isRegularLoggingEnabled
public boolean isRegularLoggingEnabled()Determine whether regular logging is enabled.- Returns:
- true if log entries are forwarded to the regular global logger
-
hasStructuredContents
public boolean hasStructuredContents()Determine whether structured entries have been recorded.- Returns:
- true if at least one structured entry exists
-
beginSection
Start a structured log section.- Parameters:
name- section namedefaultOpen- true if the generated HTML section should be initially open
-
beginSection
Start a closed structured log section.- Parameters:
name- section name
-
closeSection
public void closeSection()Close the current structured log section. -
generateHtml
Generate an HTML representation of the structured log.- Returns:
- the generated HTML
-
generateHtml
Same as generateHtml but per blocks. To use if result is too large.- Parameters:
out- output streamcharset- output charset
-
getName
Description copied from interface:ILoggerGet the logger name. -
setName
Set the logger name.- Parameters:
name- logger name
-
setEnabledLevel
public void setEnabledLevel(int level) Description copied from interface:ILoggerSet the cut-off level for a logger.- Specified by:
setEnabledLevelin interfaceILogger- Parameters:
level- the cut-off level: all logging calls with a level equal to or above the cut-off will be displayed
-
getEnabledLevel
public int getEnabledLevel()Description copied from interface:ILoggerRetrieve the cut-off level for that logger.- Specified by:
getEnabledLevelin interfaceILogger- Returns:
- the level, a number between 0 and
GlobalLog.LEVEL_CATCHING
-
log
Description copied from interface:ILoggerLog a string message. -
log
Log a structured message with an explicit display importance.- Parameters:
importance- structured display importancelevel- log levelraw- true to bypass regular log prefixes and newline suffixesformat- format string if parameters are provided, else plain messageparams- optional format parameters
-
i
Description copied from interface:ILoggerReserved for internal logging. In Release builds, calling this method does nothing. -
iH
Log an internal highlighted message.- Parameters:
format- format string if parameters are provided, else plain messageparams- optional format parameters
-
iHH
Log an internal section-level highlighted message.- Parameters:
format- format string if parameters are provided, else plain messageparams- optional format parameters
-
iHHH
Log an internal subtitle-level highlighted message.- Parameters:
format- format string if parameters are provided, else plain messageparams- optional format parameters
-
iHHHH
Log an internal title-level highlighted message.- Parameters:
format- format string if parameters are provided, else plain messageparams- optional format parameters
-
iHHHHH
Log an internal chapter-level highlighted message.- Parameters:
format- format string if parameters are provided, else plain messageparams- optional format parameters
-
iL
Log an internal low-importance message.- Parameters:
format- format string if parameters are provided, else plain messageparams- optional format parameters
-
i
Log an internal message with an explicit structured display importance.- Parameters:
importance- structured display importanceformat- format string if parameters are provided, else plain messageparams- optional format parameters
-
iBreak
public void iBreak()Insert one visual break in the structured log. -
iBreak
public void iBreak(int cnt) Insert visual breaks in the structured log.- Parameters:
cnt- number of breaks to insert
-
iSeparator
public void iSeparator()Insert a visual separator in the structured log. -
trace
Description copied from interface:ILoggerLog a trace message. -
fine
Description copied from interface:ILoggerAlias fortrace(). Log a trace message. -
debug
Description copied from interface:ILoggerLog a debug message. -
info
Description copied from interface:ILoggerLog an information message. -
warn
Description copied from interface:ILoggerLog a warning message. -
warning
Description copied from interface:ILoggerAlias forwarn(). Log a warning message. -
error
Description copied from interface:ILoggerLog an error message. -
severe
Description copied from interface:ILoggerAlias forerror(). Log an error message. -
catching
Description copied from interface:ILoggerLog an exception's stack trace. -
catching
Description copied from interface:ILoggerLog an exception's stack trace, prefixed by an optional message. -
catching
Description copied from interface:ILoggerLog an exception's stack trace, prefixed by an optional message. -
catchingSilent
Description copied from interface:ILoggerLog an exception at the debug level.- Specified by:
catchingSilentin interfaceILogger- Parameters:
t- the throwable
-
status
Description copied from interface:ILoggerLog a transient status message (STATUS). Status messages are not directed to the regular output destinations; instead, they are directed to thestatus sinks. Only the newest message is stored in the sink.
-