Class LogConsoleStyle

java.lang.Object
ca.corbett.extras.logging.LogConsoleStyle

public final class LogConsoleStyle extends Object
Represents configuration options for a specific LogConsole message style. A "Style" here refers to the font and colour options for specific types of log messages. LogConsoleStyles are grouped together into a LogConsoleTheme, which contains one or more styles.

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 Details

    • LogConsoleStyle

      public LogConsoleStyle()
      Creates a style with all default properties and no matchers.
  • Method Details

    • getLogLevel

      public Level 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

      public void setLogLevel(Level logLevel)
      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

      public String 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

      public void setLogToken(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. 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

      public Color getFontColor()
      Returns the font colour associated with this style.
      Returns:
      A Color object, will never be null.
    • setFontColor

      public void setFontColor(Color fontColor)
      Sets the font colour associated with this style.
      Parameters:
      fontColor - A Color object. Null values are ignored.
    • getFontBgColor

      public Color 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

      public void setFontBgColor(Color fontBgColor)
      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

      public void setFontFamilyName(String family)
      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

      public String 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

      public void addChangeListener(ChangeListener listener)
      Register to receive notifications when any style properties are changed.
      Parameters:
      listener - The listener to add.
    • removeChangeListener

      public void removeChangeListener(ChangeListener listener)
      Unregister from receiving notifications when style properties are changed.
      Parameters:
      listener - The listener to add.
    • saveToProps

      public void saveToProps(Properties props, String prefix)
    • loadFromProps

      public void loadFromProps(Properties props, String prefix)