-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae29164
commit 33edb49
Showing
14 changed files
with
644 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# API reference | ||
|
||
::: tinylogging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [4.2.0] - 2025-01-17 | ||
|
||
### Added | ||
|
||
- Optional parameter `message_thread_id` for handlers `AsyncTelegramHandler` and `TelegramHandler` | ||
|
||
## [4.1.0] - 2025-01-17 | ||
|
||
### Added | ||
|
||
- Added emoji support for log levels in `Formatter` | ||
|
||
### Changed | ||
|
||
- Changed the default time format in `TelegramFormatter` from `[%H:%M:%S]` to `%H:%M:%S` | ||
|
||
### Fixed | ||
|
||
- Fixed an issue where messages could be displayed even when the logger was disabled | ||
|
||
## [4.0.0] - 2025-01-14 | ||
|
||
### Added | ||
|
||
- Handler for sending logs to Telegram (`AsyncTelegramHandler`, `TelegramHandler`) (#4) | ||
- New formatter `TelegramFormatter` for processing and formatting messages sent to Telegram | ||
- New dependency: `httpx` for working with the Telegram API | ||
|
||
### Removed | ||
|
||
- Dropped support for Python 3.8 | ||
|
||
## [3.3.0] - 2025-01-11 | ||
|
||
### Fixed | ||
|
||
- Fixed an issue in `LoggingAdapterHandler` where the attributes `filename`, `function`, and `line` were not set for the `Record` object | ||
|
||
### Changed | ||
|
||
- Reorganized imports | ||
|
||
## [3.2.0] - 2024-11-01 | ||
|
||
### Fixed | ||
|
||
- Error in detecting stack depth (#3) | ||
|
||
## [3.1.0] - 2024-10-31 | ||
|
||
### Added | ||
|
||
- New attributes for the `Record` class: `filename`, `line`, `basename`, `relpath`, `function` | ||
|
||
### Changed | ||
|
||
- In the default template (attribute `template`) for the `Formatter` class, the relative path to the file and line are displayed | ||
|
||
## [3.0.0] - 2024-10-13 | ||
|
||
### Added | ||
|
||
- Asynchronous support | ||
- New dependency: `anyio` | ||
|
||
### Changed | ||
|
||
- Changed structure and module imports for better code organization | ||
|
||
## [2.2.0] - 2024-10-05 | ||
|
||
### Fixed | ||
|
||
- Issue #2 | ||
|
||
## [2.1.0] - 2024-10-05 | ||
|
||
### Added | ||
|
||
- `LoggingAdapterHandler`: an adapter for integration with the `logging` module allowing the use of custom handlers (`BaseHandler`, `StreamHandler`, etc.) with standard Python loggers | ||
|
||
## [2.0.0] - 2024-10-04 | ||
|
||
### Fixed | ||
|
||
- Issue #1 | ||
|
||
## [1.0.0] - 2024-10-04 | ||
|
||
### Added | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# tinylogging | ||
|
||
 | ||
 | ||
 | ||
 | ||
 | ||
 | ||
|
||
## Installation | ||
|
||
```bash | ||
pip install tinylogging | ||
``` | ||
|
||
## Usage | ||
|
||
### New logger | ||
|
||
```python | ||
from tinylogging import Logger, Level | ||
|
||
logger = Logger(name="my_logger", level=Level.DEBUG) | ||
``` | ||
|
||
### Logging messages | ||
|
||
```python | ||
logger.info("This is an info message.") | ||
logger.error("This is an error message.") | ||
logger.debug("This is a debug message.") | ||
``` | ||
|
||
### Logging to a file | ||
|
||
```python | ||
from tinylogging import FileHandler | ||
|
||
file_handler = FileHandler(file_name="app.log", level=Level.WARNING) | ||
logger.handlers.add(file_handler) | ||
|
||
logger.warning("This warning will be logged to both console and file.") | ||
``` | ||
|
||
### Custom formatting | ||
|
||
```python | ||
from tinylogging import Formatter | ||
|
||
formatter = Formatter(template="{time} - {name} - {level} - {message}", colorize=False) | ||
logger = Logger(name="custom_logger", formatter=formatter) | ||
logger.info("This log message uses a custom format.") | ||
``` | ||
|
||
### Disabling logging | ||
|
||
```python | ||
logger.disable() | ||
logger.info("This message will not be logged.") | ||
logger.enable() | ||
``` | ||
|
||
### Async support | ||
|
||
```python | ||
import asyncio | ||
from tinylogging import AsyncLogger, AsyncFileHandler | ||
|
||
|
||
async def main(): | ||
logger = AsyncLogger(name="async_logger") | ||
|
||
file_handler = AsyncFileHandler(file_name="app.log") | ||
logger.handlers.add(file_handler) | ||
|
||
await logger.info("This is an info message.") | ||
await logger.error("This is an error message.") | ||
await logger.debug("This is a debug message.") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main) | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the [MIT License](https://github.com/HamletSargsyan/tinylogging/blob/main/LICENSE). |
Oops, something went wrong.