Class LogConsoleStyle
A LogConsoleStyle consists of either a log Level or a log string token, or both. Styles associated with a specific log Level will be applied to any message that is logged at that level (example: all INFO messages or all WARNING messages). Styles associated with a string token will be applied to any log message that contains that string token (example: "error" or "failure"). If both a Level and a string token are supplied, then they must both match in order to apply this style.
If a log message doesn't meet the criteria of any given Style within a Theme, then it is styled using the "Default" style (which can be customized but not removed from the LogConsoleTheme).
If more than one style in a given theme matches a given log message, a matching algorithm is applied as described in LogConsoleTheme.
- Since:
- 2023-03-17
- Author:
- scorbo2
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a style with all default properties and no matchers. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(ChangeListener listener) Register to receive notifications when any style properties are changed.Returns the font background colour for this style, or null if one is not set.Returns the font colour associated with this style.Returns the font family name currently in effect for this style.intReturns the Level matcher - that is, the log level to which this style will be applied.Returns the log token matcher - that is, a string to search for in log messages to see if this style should be applied.booleanisBold()booleanisItalic()booleanbooleanvoidloadFromProps(Properties props, String prefix) voidremoveChangeListener(ChangeListener listener) Unregister from receiving notifications when style properties are changed.voidsaveToProps(Properties props, String prefix) voidsetFontBgColor(Color fontBgColor) Sets a background colour for this style.voidsetFontColor(Color fontColor) Sets the font colour associated with this style.voidsetFontFamilyName(String family) Due to limitations in JTextPane, we can only accept a font "family" name instead of a specific font name.voidsetFontPointSize(int fontPointSize) voidsetIsBold(boolean isBold) voidsetIsItalic(boolean isItalic) voidsetIsUnderline(boolean isUnderline) voidsetLogLevel(Level logLevel) Sets the Level matcher to use - that is, the log level to which this style will be applied.voidsetLogToken(String logToken, boolean isCaseSensitive) Sets the log token matcher - that is, a string to search for in log messages to see if this style should be applied.
-
Constructor Details
-
LogConsoleStyle
public LogConsoleStyle()Creates a style with all default properties and no matchers.
-
-
Method Details
-
getLogLevel
Returns the Level matcher - that is, the log level to which this style will be applied. A value of Level.ALL means the style will be applied to all log messages. A value of null (the default) means this style will not be applied based on log Level.- Returns:
- A Level value, or null if not Level matcher is to be applied.
-
setLogLevel
Sets the Level matcher to use - that is, the log level to which this style will be applied. A value of Level.ALL means the style will be applied to all log messages. A value of null means this style will not be applied based on log Level.- Parameters:
logLevel- A Level value as described above.
-
getLogToken
Returns the log token matcher - that is, a string to search for in log messages to see if this style should be applied. A value of null (the default) means that this style will not be applied based on log message contents.- Returns:
- A String as described above.
-
setLogToken
Sets the log token matcher - that is, a string to search for in log messages to see if this style should be applied. A value of null means that this style will not be applied based on log message contents.- Parameters:
logToken- A String as described above, or null.isCaseSensitive- whether or not to treat logToken in a case sensitive manner.
-
isLogTokenCaseSensitive
public boolean isLogTokenCaseSensitive() -
getFontColor
Returns the font colour associated with this style.- Returns:
- A Color object, will never be null.
-
setFontColor
Sets the font colour associated with this style.- Parameters:
fontColor- A Color object. Null values are ignored.
-
getFontBgColor
Returns the font background colour for this style, or null if one is not set. If the value is null, the background colour of the theme itself will be applied.- Returns:
- A Color object, or null.
-
setFontBgColor
Sets a background colour for this style. If null is specified, the background colour of the theme itself will be used.- Parameters:
fontBgColor- A Color object, or null to fall back to the theme background color.
-
setFontFamilyName
Due to limitations in JTextPane, we can only accept a font "family" name instead of a specific font name. Allowable values are "MonoSpaced", "Serif", or "SansSerif" (case sensitive).- Parameters:
family- A font family name as described above.
-
getFontFamilyName
Returns the font family name currently in effect for this style.- Returns:
- One of "MonoSpaced", "Serif", or "SansSerif"
-
isBold
public boolean isBold() -
setIsBold
public void setIsBold(boolean isBold) -
isItalic
public boolean isItalic() -
setIsItalic
public void setIsItalic(boolean isItalic) -
isUnderline
public boolean isUnderline() -
setIsUnderline
public void setIsUnderline(boolean isUnderline) -
getFontPointSize
public int getFontPointSize() -
setFontPointSize
public void setFontPointSize(int fontPointSize) -
addChangeListener
Register to receive notifications when any style properties are changed.- Parameters:
listener- The listener to add.
-
removeChangeListener
Unregister from receiving notifications when style properties are changed.- Parameters:
listener- The listener to add.
-
saveToProps
-
loadFromProps
-