Logging System API


JJMumbleBot uses a custom logging system built on top of the standard python logging module.


Custom Logging

To add logging functionality to third party plugins, follow these steps:

  1. Import the logging utility:
    from JJMumbleBot.lib.utils.logging_utils import log
  2. If you wish to print the event to the console in addition to logging it, import the print utility:
    from JJMumbleBot.lib.utils.print_utils import PrintMode
  3. Import the severity/origin resource strings as necessary:
    from JJMumbleBot.lib.resources.strings import *
  4. Use the log method to log/print events.
    Refer to the logging API provided at the bottom of this page for more information on the method.
    Example usage: log(INFO, "Initialized plugin!", origin=L_STARTUP, print_mode=PrintMode.REG_PRINT.value)

Log API

log (LOG_SEVERITY, LOG_MESSAGE(S), LOG_ORIGIN (Optional), LOG_ERROR_TYPE (Optional), LOG_PRINTING (Optional))

  1. LOG_SEVERITY: This is the severity of the event which is being logged.
    The severity strings must be imported as required:
    from JJMumbleBot.lib.resources.strings import INFO,DEBUG,WARNING,ERROR,CRITICAL
    The available severities are:
    1. INFO: Standard severity which is meant to provide information on an event.
    2. DEBUG: Used to log debug events.
    3. WARNING: Used to log events that could possible disrupt services.
    4. ERROR: Used to log events that cause errors within the application.
    5. CRITICAL: Used to log events that cause critical errors, usually resulting in the crashing of the application.
  2. LOG_MESSAGE(S): This is the content that is to be logged from the event.
    The message can either be a string or a List[string]:
    1. Single Message: "This is my message."
    2. Multi-line Message: ["Message 1", "Message 2"]
  3. LOG_ORIGIN (Optional): This is an optional parameter that indicates the origin of the log event which is used to indicate during what process the event occurred.
    The origin strings must be imported as required:
    from JJMumbleBot.lib.resources.strings import L_GENERAL, L_COMMAND, L_STARTUP, etc...
    The origin parameter is optional and will default to L_GENERAL if not provided.
    The available origins are:
    1. L_GENERAL: Used to indicate an event with a non-specific origin.
    2. L_USER_PRIV: Used to indicate an event related to user privileges.
    3. L_DATABASE: Used to indicate an event related to database operations.
    4. L_COMMAND: Used to indicate an event related to command processing.
    5. L_STARTUP: Used to indicate an event related to startup procedures.
    6. L_SHUTDOWN: Used to indicate an event related to shutdown procedures.
    7. L_ALIASES: Used to indicate an event related to aliases.
    8. L_LOGGING: Used to indicate an event related to logging.
    9. L_DEPENDENCIES: Used to indicate an event related to dependency handling.
    10. L_WEB_INTERFACE: Used to indicate an event related to the web interface.
    11. L_PLUGIN: Used to indicate a non-specific plugin related event.
  4. LOG_ERROR_TYPE (Optional): This is an optional parameter that indicates the type of error that occurred from the event.
    The error message can be any string as it is specific to the event:
    Examples:
    1. "MyPlugin_SpecificError"
    2. "MyPlugin_RandomError"
  5. LOG_PRINTING (Optional): This is an optional parameter that allows the log event to also be printed to the console.
    By default, if a value is not provided then event will not be printed to the console.
    The print mode must be imported as required:
    from JJMumbleBot.lib.utils.print_utils import PrintMode
    The available print modes are:
    1. PrintMode.REG_PRINT.value: Use this when you want to print the log event message to the console under regular operation.
    2. PrintMode.VERBOSE_PRINT.value: Use this when you want to print the log event message to the console only when verbose mode is enabled.

Example Saved Log:

image