A native python3 logging module for quickly setting up and managing logs.
Project description
logger
An easy-to-use logger class that can intelligently handle pushing stdout messages between files/terminals based off configured options. Extremely useful for setting up a whole logger.Logging()
instance without worrying about configuring format/file-handling for scripts/applications.
Features
- Has a built-in logging style: [DATE TIME] [LEVEL] [LOG NAME] [LOG COUNT] - [MESSAGE]
- supports python's built-in
with()
statement - Can figure out whether to log a specific message to a file or log based off the Level configured such as:
- Level 0/None - Log everything to the terminal.
- Level 1 - Log critical to file. Log warnings/ok/info to terminal.
- Level 2 - Log critical/error to file. Log warnings/info/ok to terminal.
- Level 3 - Log errors/warnings to file. Log INFO/OK the terminal
- Level 4 - Log everything into file
- Dynamically switch log levels and logging files with
set_log_file()
andset_log_level()
respectively. - Enable/Disable logging as needed.
Installation
git clone https://github.com/henryriveraCS/logger
-
Move
logger/logger.py
into your project directory -
Because we don't use any third party libraries the installation is done :^)
Usage
#python3
from logger import Log
items = ["item1", "item2", "item3", "item4", "item5"]
my_logger = Log(Name="My Logger")
my_logger.info(items[0])
my_logger.ok(items[1])
my_logger.warning(items[2])
my_logger.error(items[3])
my_logger.critical(items[4])
# pointing logger to example.log with log level set to 2
my_logger.set_log_file("example.log")
my_logger.set_log_level(2)
my_logger.ok("Test OK")
my_logger.error("Test Error")
Results from running example.py under the example/
folder
Terminal:
File:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for logger_henryriveracs-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd39ee9372a0281328dd0db386839c407e45763be881f0e34ef2c001cc1bf1cb |
|
MD5 | ee76c469cc580d9a48742803ff0028d0 |
|
BLAKE2b-256 | 341d347d04568ef86a1a5993a612f93c4183bfc6585ef4ac9cb819872acc8c7b |
Close
Hashes for logger_henryriveracs-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 507a0e539c8b59b765828b4b7690c1b8946c82cc2ba93d7b1a7e2ebfd9c92b80 |
|
MD5 | e3a8e5b08d7068c051cdb3cf47b2ab8b |
|
BLAKE2b-256 | c4ef60fcc0b273fc5325637055fa135054a0fe45c2fc00ef36b7115c10033392 |