Skip to main content

A simple logger with a convenient log message format.

Project description

logo

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 hashes)

Uploaded Source

Built Distribution

lognet-3.0.2-py3-none-any.whl (10.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page