Python logger wrapper for logging to console and file
Project description
1. Overview
logzilla is a simple yet capable python logging wrapper that gives you better defaults like coloured output.
2. Table of Contents
3. Installation and usage
3.1. Installation
It requires Python 3.8.1+ to run.
pip install logzilla
3.2. Examples
In both examples a .log folder is created in the output directory with the
following files corresponding to the date and time of execution of each example:
2023.04.10 15.54.23_logzilla.log2023.04.10 16.18.29_logzilla.log
Sample log file output:
2023/04/10 15:55:16: logzilla.py:115: INFO: LogZilla: Root logger initialized.
2023/04/10 15:55:16: logzilla.py:121: INFO: ********************************************************************************
2023/04/10 15:55:16: logzilla.py:122: INFO: ******************************** LogZilla Demo *********************************
2023/04/10 15:55:16: logzilla.py:123: INFO: ********************************************************************************
2023/04/10 15:55:16: logzilla.py:183: DEBUG: debug message
2023/04/10 15:55:16: logzilla.py:184: INFO: info message
2023/04/10 15:55:16: logzilla.py:185: WARNING: warning message
2023/04/10 15:55:16: logzilla.py:186: ERROR: error message
2023/04/10 15:55:16: logzilla.py:187: CRITICAL: critical message
2023/04/10 15:55:16: logzilla.py:137: INFO: Execution Time of <main>: 0:00:00.012001 hh:mm::ss
3.3. Example 1: Minimal example
@log_execution_time
def main() -> None:
current_file_path = Path(__file__).absolute()
current_file_dir = current_file_path.parent
LogZilla.init_root_logger(
output_dir=current_file_dir,
console_level=logging.DEBUG,
file_level=logging.DEBUG,
)
log_title("LogZilla Demo")
logger = logging.getLogger(__name__)
logger.debug("debug message")
logger.info("info message")
logger.warning("warning message")
logger.error("error message")
logger.critical("critical message")
Output:
3.4. Example 2: No file info to console
@log_execution_time
def main() -> None:
current_file_path = Path(__file__).absolute()
current_file_dir = current_file_path.parent
LogZilla.init_root_logger(
output_dir=current_file_dir,
console_level=logging.DEBUG,
file_level=logging.DEBUG,
no_console_file_info=True,
)
log_title("LogZilla Demo")
logger = logging.getLogger(__name__)
logger.debug("debug message")
logger.info("info message")
logger.warning("warning message")
logger.error("error message")
logger.critical("critical message")
Output:
4. Other Docs
5. Future Improvements
- add unit tests
- add pre-commit hooks for
black, pylint, flake8, bandit, tox, pytestfor development environment
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logzilla-0.1.0.tar.gz.
File metadata
- Download URL: logzilla-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a6789b1681e4c034c004e45866178dec2b36431b00fcc5de77a45323c5d2737
|
|
| MD5 |
e6ba9f14c5f2ff6df250fdc1f278e6bf
|
|
| BLAKE2b-256 |
6cb0e50c82f92dfad3e8326eb5738cf4cd0332504c37b5970014e19fb25aa4e5
|
File details
Details for the file logzilla-0.1.0-py3-none-any.whl.
File metadata
- Download URL: logzilla-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afe28bc54d92d0ae4f53296bbc408dde8043320c1ac1b6eb7d0ade7aa8a82279
|
|
| MD5 |
2d49ed159296b8d2b121310908bbc74e
|
|
| BLAKE2b-256 |
9127847bc7af467fcf004485b7e11ccebbd86073b895527663e1ccb0a2d44604
|