A simple logger with a convenient log message format.
Project description
Lognet
Lognet is a lightweight logging library for Python, designed to simplify the process of logging messages with different levels of severity. It provides an easy-to-use interface, customization options.
Features
-
Log Levels: Log messages with different severity levels, including DEBUG, INFO, WARNING, ERROR, and EXCEPTION.
-
Convenient log message formatting
-
Console and File Logging: Log messages to the console, a file, or both.
Installation
Install Lognet Logger using pip:
pip install lognet
ARCHITECTURE
lognet/
в”‚
в”њв”Ђв”Ђ core/
в”‚ в”њв”Ђв”Ђ __init__.py
в”‚ в”њв”Ђв”Ђ application/
в”‚ в”‚ в”њв”Ђв”Ђ __init__.py
в”‚ в”‚ в”њв”Ђв”Ђ logger.py
в”‚ в”‚ в”њв”Ђв”Ђ handlers/
в”‚ в”‚ в”‚ в”њв”Ђв”Ђ handler.py
в”‚ в”‚ в”‚ в”њв”Ђв”Ђ file_handler.py
в”‚ в”‚ в”‚ в””в”Ђв”Ђ console_handler.py
в”‚ в”‚ в”њв”Ђв”Ђ formatters/
в”‚ в”‚ в”‚ в””в”Ђв”Ђ log_formatter.py
в”‚ в”њв”Ђв”Ђ domain/
в”‚ в”‚ в”њв”Ђв”Ђ __init__.py
в”‚ в”‚ в”њв”Ђв”Ђ log_levels.py
в”‚ в”‚ в””в”Ђв”Ђ log_entity.py
в”‚ в”њв”Ђв”Ђ configuration/
в”‚ в”‚ в”њв”Ђв”Ђ __init__.py
в”‚ в”‚ в”њв”Ђв”Ђ handler_configurator.py
в”‚ в”‚ в””в”Ђв”Ђ logger_config.py
Usage
Basic Example
from lognet import Logger, LogLevel, LoggerConfig, ConsoleHandler, HandlerConfigurator
logger_config = LoggerConfig(min_level=LogLevel.DEBUG,
handler_configurator=HandlerConfigurator(console_handler=ConsoleHandler()))
logger = Logger(logger_config)
logger.log(level=LogLevel.INFO, message="Example log message")
Change format
from lognet import Logger, LogLevel, LoggerConfig, ConsoleHandler, HandlerConfigurator
logger_config = LoggerConfig(log_format="[{time}] [{log_level}] {message}",
min_level=LogLevel.DEBUG,
handler_configurator=HandlerConfigurator(console_handler=ConsoleHandler()))
logger = Logger(logger_config)
logger.log(level=LogLevel.INFO, message="Example log message")
logger.log(level=LogLevel.ERROR, message="Example error message")
File Handler
from lognet import Logger, LogLevel, LoggerConfig, HandlerConfigurator, FileHandler
logger_config = LoggerConfig(min_level=LogLevel.DEBUG,
handler_configurator=HandlerConfigurator(console_handler=FileHandler(file_name="log.txt")))
logger = Logger(logger_config)
logger.log(level=LogLevel.INFO, message="Example log message")
logger.log(level=LogLevel.ERROR, message="Example error message")
## Future updates
Ideas that I will try to implement
- multithreading
- async
- logging to database
- Filtration
- Settings for each message level separately
- Integration with metrics and tracing
- Support various output formats
- adding tags
- logging in json
## Connect with me/bug/request/suggestion
Check the FEEDBACK.md for information
## Documentation
Check the USAGE.md file for comprehensive examples and configuration details.
## Changelog
Review the CHANGELOG.md file for information on the latest updates and changes.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lognet-3.0.2.tar.gz
(8.3 kB
view details)
Built Distribution
lognet-3.0.2-py3-none-any.whl
(10.6 kB
view details)
File details
Details for the file lognet-3.0.2.tar.gz
.
File metadata
- Download URL: lognet-3.0.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3b2b742491cd2512cee9d67c09bda627c6d14f69ad12bf359c84f5c0aff12e6 |
|
MD5 | 207f76e80f3ffc59aee74ccebbb82514 |
|
BLAKE2b-256 | 853d6154fd5512c81e694fc530b20393191f1a12ee6863a84cf24b71e0addba9 |
File details
Details for the file lognet-3.0.2-py3-none-any.whl
.
File metadata
- Download URL: lognet-3.0.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccfb5f03a9d0d162a41f635a627a1f6d61fc65e084f7cdcb2e1dbb5265611042 |
|
MD5 | 713ba88e8a7bb5a8d99f2f44389f7774 |
|
BLAKE2b-256 | 12c383465e0b9de418725c92265d5bc821abfadc8eb4b436c20f8830eee62bdd |