Utils - LeConstellationniste/Discord.py-Framework- GitHub Wiki

Utils

Class Logs

Static class for create logs (colored logs if the colorama package is found).

The logs created with this class follow this format :
[yyyy-mm-dd to hh:mm:ss][{TYPE_LOG}] {message}
{TYPE_LOG} can be INFO, DEBUG, ERROR, WARNING or SUCCESS. And {message} a message pass in argument.

Attributes class

The color attributes are initialized only if colorama package is imported!

Attributes Name colorama must be installed Description Default value
path_info NO The default path for logs info. None (logs are not save)
path_debug NO The default path for logs debug. None (logs are not save)
path_warning NO The default path for logs warning. None (logs are not save)
path_error NO The default path for logs error. None (logs are not save)
path_success NO The default path for logs success. None (logs are not save)
date_fmt NO The date format, see datetime format "%Y-%m-%d to %H:%M:%S"
color_debug YES The color use for debug logs colorama.Fore.CYAN
color_info YES The color use for info logs colorama.Fore.WHITE
color_warning YES The color use for warning logs colorama.Fore.YELLOW
color_error YES The color use for error logs colorama.Fore.RED
color_success YES The color use for success logs colorama.Fore.GREEN

Static methods

  • info

    • Description: Static method to display info logs. If path_save argument is not None, the log is save in a file with this path.

    • Arguments:

      • message: str - The message logs to display.
      • OPTIONNAL[path_save]: str, default None - The path where the log is saved, if None, the log is not saved.
  • debug

    • Description: Static method to display debug logs. If path_save argument is not None, the log is save in a file with this path.

    • Arguments:

      • message: str - The message logs to display.
      • OPTIONNAL[path_save]: str, default None - The path where the log is saved, if None, the log is not saved.
  • warning

    • Description: Static method to display warning logs. If path_save argument is not None, the log is save in a file with this path.

    • Arguments:

      • message: str - The message logs to display.
      • OPTIONNAL[path_save]: str, default None - The path where the log is saved, if None, the log is not saved.
  • error

    • Description: Static method to display error logs. If path_save argument is not None, the log is save in a file with this path.

    • Arguments:

      • message: str - The message logs to display.
      • OPTIONNAL[path_save]: str, default None - The path where the log is saved, if None, the log is not saved.
  • success

    • Description: Static method to display success logs. If path_save argument is not None, the log is save in a file with this path.

    • Arguments:

      • message: str - The message logs to display.
      • OPTIONNAL[path_save]: str, default None - The path where the log is saved, if None, the log is not saved.

Utils functions

  • replace_multiple

    • Description: A function to replace several occurrences of a str in a specified occurrence.

    • Arguments:

      • _str: str - The str where occurrences must be replace.
      • to_replace: list[str], List of occurrences to replace.
      • new_char: str - The new occurrence.
    • Return: The new str with occurrences of to_replace replace by new_char.

  • list_to_str

    • Description: A function which convert a list in a str enumeration (delete the characters "[", "]").

    • Arguments:

      • _list: list - The list to convert in a str.
    • Return: str.

  • safe_delete

    • Description: A function to delete a discord.Message in a secure way.

    • Arguments:

      • message: [discord.Message] - The discord message to delete.
      • OPTIONNAL[delay_]: int - the delay before delete the message in seconds. OPTIONNAL[warning]: bool, Default: True - If True, a warning logs is displayed if there is a error.