Class DebugCtl

java.lang.Object
org.ka2ddo.util.DebugCtl

public class DebugCtl extends Object
This class manages the debug controls for the application, independent of how the controls are set by any user interface. As such, code wanting to test the debug controls to decide whether to output debug data can do so without being locked to a particular application.
Author:
Andrew Pavlin, KA2DDO
  • Method Details

    • setDebug

      public static void setDebug(String categoryName, boolean setting)
      Specify if a specific category of debug messages should be printed out.
      Parameters:
      categoryName - String name of category to enable debug logging for
      setting - boolean true or false to enable or disable debugging this category
    • isDebug

      public static boolean isDebug()
      Indicate if debug messages should be printed out.
      Returns:
      boolean true if debug messages should be printed
    • isDebug

      public static boolean isDebug(String categoryName)
      Indicate if a specific category of debug messages should be printed out.
      Parameters:
      categoryName - String name of category to enable debug logging for
      Returns:
      boolean true if the named category of debug messages should be printed
    • isDebugOnly

      public static boolean isDebugOnly(String categoryName)
      Indicate if a specific category of debug messages should be printed out.
      Parameters:
      categoryName - String name of category to enable debug logging for
      Returns:
      boolean true if the named category of debug messages should be printed
    • addDbgListener

      public static void addDbgListener(DebugCtl.DbgListener l, String categoryName, String tagsToDisplayName)
      Register a listener for the specified categories of debug events. If registered for the "all" category, such listeners will be informed of all debug changes and given the name of the category actually changed.
      Parameters:
      l - DbgListener to register (or null to just register a type and description)
      categoryName - String names of debug categories; null implies "all"
      tagsToDisplayName - String tag name for displaying the categories for dynamic debug level switching from the UI
    • removeDbgListener

      public static void removeDbgListener(DebugCtl.DbgListener l, String... categoryNames)
      Unregister a listener for the specified categories of debug events.
      Parameters:
      l - DbgListener to unregister
      categoryNames - array of String names of debug categories; zero-length implies an array of "all"
    • getCategoryCodesAndTagNames

      public static Set<Map.Entry<String,String>> getCategoryCodesAndTagNames()
      Get the list of known dynamically modifiable debug categories and their tags for locale-specific descriptions.
      Returns:
      read-only Set of Map.Entry of category ID to resource tag names
    • getCategorySettings

      public static List<Map.Entry<String,Boolean>> getCategorySettings()
      Get the list of known dynamically modifiable debug categories and their tags for locale-specific descriptions.
      Returns:
      read-only Set of Map.Entry of category ID to resource tag names
    • getCategoryTag

      public static String getCategoryTag(String category)
      Get the localization tag name for a description of the category.
      Parameters:
      category - String category name
      Returns:
      String tag for looking up localized description in ResourceBundles, or null if no known tag