Module de.carne

Class Logs


  • public final class Logs
    extends java.lang.Object
    Utility class providing Log related functions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONFIG_BOOT
      Name of pre-defined boot logging config.
      static java.lang.String CONFIG_DEBUG
      Standard name for debug logging config.
      static java.lang.String CONFIG_DEFAULT
      Standard name for default logging config.
      static java.lang.String CONFIG_VERBOSE
      Standard name for verbose logging config.
      static java.util.logging.ErrorManager DEFAULT_ERROR_MANAGER
      Default ErrorManager instance to use for error reporting.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void applyLevelConfig​(java.lang.String levelConfig)
      Applies individual level configuration to the current configuration.
      static void flush()
      FLushs all currently configured Handler instance (e.g. during application exit).
      static boolean getBooleanProperty​(java.util.logging.LogManager manager, java.lang.String name, boolean defaultValue)
      Gets a boolean property from a LogManager's current configuration.
      static @Nullable java.util.logging.Filter getFilterProperty​(java.util.logging.LogManager manager, java.lang.String name, @Nullable java.util.logging.Filter defaultValue)
      Gets a Filter property from a LogManager's current configuration.
      static java.util.logging.Formatter getFormatterProperty​(java.util.logging.LogManager manager, java.lang.String name, java.util.logging.Formatter defaultValue)
      Gets a Formatter property from a LogManager's current configuration.
      static int getIntProperty​(java.util.logging.LogManager manager, java.lang.String name, int defaultValue)
      Gets a int property from a LogManager's current configuration.
      static java.util.logging.Level getLevelProperty​(java.util.logging.LogManager manager, java.lang.String name, LogLevel defaultValue)
      Gets a Level property from a LogManager's current configuration.
      static java.lang.String getStringProperty​(java.util.logging.LogManager manager, java.lang.String name, java.lang.String defaultValue)
      Gets a String property from a LogManager's current configuration.
      static @NonNull java.lang.String[] getStringsProperty​(java.util.logging.LogManager manager, java.lang.String name)
      Gets a String array property from a LogManager's current configuration.
      static void readConfig​(java.lang.String config)
      Reads and applies a LogManager configuration.
      static void readConfig​(java.net.URL config)
      Reads and applies a LogManager configuration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CONFIG_BOOT

        public static final java.lang.String CONFIG_BOOT
        Name of pre-defined boot logging config.
        See Also:
        Constant Field Values
      • DEFAULT_ERROR_MANAGER

        public static final java.util.logging.ErrorManager DEFAULT_ERROR_MANAGER
        Default ErrorManager instance to use for error reporting.
      • CONFIG_DEFAULT

        public static final java.lang.String CONFIG_DEFAULT
        Standard name for default logging config.
        See Also:
        Constant Field Values
      • CONFIG_VERBOSE

        public static final java.lang.String CONFIG_VERBOSE
        Standard name for verbose logging config.
        See Also:
        Constant Field Values
      • CONFIG_DEBUG

        public static final java.lang.String CONFIG_DEBUG
        Standard name for debug logging config.
        See Also:
        Constant Field Values
    • Method Detail

      • flush

        public static void flush()
        FLushs all currently configured Handler instance (e.g. during application exit).
      • readConfig

        public static void readConfig​(java.lang.String config)
                               throws java.io.IOException
        Reads and applies a LogManager configuration.
        Parameters:
        config - the name of the configuration to read.
        Throws:
        java.io.IOException - if an I/O error occurs while reading the configuration.
      • readConfig

        public static void readConfig​(java.net.URL config)
                               throws java.io.IOException
        Reads and applies a LogManager configuration.
        Parameters:
        config - the URL of the configuration to read.
        Throws:
        java.io.IOException - if an I/O error occurs while reading the configuration.
      • applyLevelConfig

        public static void applyLevelConfig​(java.lang.String levelConfig)
        Applies individual level configuration to the current configuration.

        The level configuration to apply is defined as follows: (<logger name>=<level name>)*

        Parameters:
        levelConfig - the level configuration to apply.
      • getStringProperty

        public static java.lang.String getStringProperty​(java.util.logging.LogManager manager,
                                                         java.lang.String name,
                                                         java.lang.String defaultValue)
        Gets a String property from a LogManager's current configuration.
        Parameters:
        manager - the LogManager to get the configuration from.
        name - the property name to evaluate.
        defaultValue - the the default value to return in case the property is undefined.
        Returns:
        the defined value or the default value if the property is undefined.
      • getStringsProperty

        public static @NonNull java.lang.String[] getStringsProperty​(java.util.logging.LogManager manager,
                                                                     java.lang.String name)
        Gets a String array property from a LogManager's current configuration.
        Parameters:
        manager - the LogManager to get the configuration from.
        name - the property name to evaluate.
        Returns:
        the defined value or the default value if the property is undefined.
      • getIntProperty

        public static int getIntProperty​(java.util.logging.LogManager manager,
                                         java.lang.String name,
                                         int defaultValue)
        Gets a int property from a LogManager's current configuration.
        Parameters:
        manager - the LogManager to get the configuration from.
        name - the property name to evaluate.
        defaultValue - the the default value to return in case the property is undefined.
        Returns:
        the defined value or the default value if the property is undefined.
      • getBooleanProperty

        public static boolean getBooleanProperty​(java.util.logging.LogManager manager,
                                                 java.lang.String name,
                                                 boolean defaultValue)
        Gets a boolean property from a LogManager's current configuration.
        Parameters:
        manager - the LogManager to get the configuration from.
        name - the property name to evaluate.
        defaultValue - the the default value to return in case the property is undefined.
        Returns:
        the defined value or the default value if the property is undefined.
      • getLevelProperty

        public static java.util.logging.Level getLevelProperty​(java.util.logging.LogManager manager,
                                                               java.lang.String name,
                                                               LogLevel defaultValue)
        Gets a Level property from a LogManager's current configuration.
        Parameters:
        manager - the LogManager to get the configuration from.
        name - the property name to evaluate.
        defaultValue - the the default value to return in case the property is undefined.
        Returns:
        the defined value or the default value if the property is undefined.
      • getFilterProperty

        public static @Nullable java.util.logging.Filter getFilterProperty​(java.util.logging.LogManager manager,
                                                                           java.lang.String name,
                                                                           @Nullable java.util.logging.Filter defaultValue)
        Gets a Filter property from a LogManager's current configuration.
        Parameters:
        manager - the LogManager to get the configuration from.
        name - the property name to evaluate.
        defaultValue - the the default value to return in case the property is undefined.
        Returns:
        the defined value or the default value if the property is undefined.
      • getFormatterProperty

        public static java.util.logging.Formatter getFormatterProperty​(java.util.logging.LogManager manager,
                                                                       java.lang.String name,
                                                                       java.util.logging.Formatter defaultValue)
        Gets a Formatter property from a LogManager's current configuration.
        Parameters:
        manager - the LogManager to get the configuration from.
        name - the property name to evaluate.
        defaultValue - the the default value to return in case the property is undefined.
        Returns:
        the defined value or the default value if the property is undefined.