Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.84 KB

README.md

File metadata and controls

58 lines (38 loc) · 1.84 KB

PRs Welcome

The tools I use in my daily life


Logger

This is a new module, I have not worked on it a lot yet, feel free to contribute to add more features or improve my code !

The Logger is a collection of classes and wrapper that provides a simple way to log messages to the console with different colors and format.

The module currently contains the following classes:

  • ColorCodes - A dataclass that contains the color value for the logger.
  • ConsoleFormatter - A class that format and color to the console.
    • It also contains a wrapper that I called the Watcher
  • FileFormatter - A class that format and output to a file.

Logger Example

from logger import init_logging

logger = init_logging("My Logger", "DEBUG", "log.log")

logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")

As you can see, the Logger uses the logging module behind the scene so most of the it's functions should work fine.

Watcher Example

Watcher is a wrapper that can easily be placed in order to track the calls of your code.

from logger.logger import init_logging
from logger.logger import ConsoleFormatter

@ConsoleFormatter.Watcher("INFO")
def addition(a, b):
    return a + b

logger = init_logging("My Logger", "DEBUG", "log.log")

logger.debug("This is debug message")
logger.debug(addition(1, 2))
logger.error("This is an error message")

The Watcher takes it's own level of logging