betterlib

A useful collection of various tools and libraries for anyone to use in their projects.


Project maintained by HENRYMARTIN5 Hosted on GitHub Pages — Theme by mattgraham

Logging

This module contains the Logger class, which is a simple and easy to use logging class that can be used to log messages to a file and to the terminal with color via colorama.

Usage

To use this module, simply import it and create a new Logger object.

from betterlib import logging

logger = logging.Logger("./myapp.log", "MyApp")

Then, you can use the logger object to log messages.

logger.info("Hello, world!")

Methods

Constructor

close()

Closes the logger and sets the active property to False.

reopen()

Reopens the logger and sets the active property to True.

log(message, level="INFO")

Logs a message to the log file and to the console.

reloadFile()

Reloads the log file. (Internaly used.)

info(message)

Logs a message with the INFO level.

warn(message)

Logs a message with the WARN level.

error(message)

Logs a message with the ERROR level.

critical(message)

Logs a message with the CRITICAL level.

debug(message)

Logs a message with the DEBUG level.