Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
HamletSargsyan committed Jan 24, 2025
1 parent ae29164 commit 33edb49
Show file tree
Hide file tree
Showing 14 changed files with 644 additions and 31 deletions.
36 changes: 18 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,70 +11,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Необязательный параметр `message_thread_id` для хендлеров `AsyncTelegramHandler` и `TelegramHandler`
- Optional parameter `message_thread_id` for handlers `AsyncTelegramHandler` and `TelegramHandler`

## [4.1.0] - 2025-01-17

### Added

- Добавлена поддержка эмодзи для уровней логов в `Formatter`
- Added emoji support for log levels in `Formatter`

### Changed

- Изменён формат времени по умолчанию в `TelegramFormatter` с `[%H:%M:%S]` на `%H:%M:%S`
- 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

- Обработчик для отправки логов в Telegram (`AsyncTelegramHandler`, `TelegramHandler`) (#4)
- Новый форматтер `TelegramFormatter` для обработки и форматирования сообщений, отправляемых в Telegram
- Зависимость `httpx` для работы с Telegram API
- 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

- Прекращена поддержка Python 3.8
- Dropped support for Python 3.8

## [3.3.0] - 2025-01-11

### Fixed

- Исправлена проблема в `LoggingAdapterHandler`, из-за которой атрибуты `filename`, `function` и `line` не устанавливались для объекта `Record`
- 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

- Ошибка при обнаружении глубины стека (#3)
- Error in detecting stack depth (#3)

## [3.1.0] - 2024-10-31

### Added

- Новые атрибуты для класса `Record`: `filename`, `line`, `basename`, `relpath`, `function`
- New attributes for the `Record` class: `filename`, `line`, `basename`, `relpath`, `function`

### Changed

- В дефолтном шаблоне (атрибут `template`) для класса `Formatter` отображаются относительный путь к файлу и строку
- 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

- Поддержка асинхронности
- Новая зависимость: `anyio`
- Asynchronous support
- New dependency: `anyio`

### Changed

- Изменена структура и импорт модулей для лучшей организации кода
- Changed structure and module imports for better code organization

## [2.2.0] - 2024-10-05

Expand All @@ -86,7 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `LoggingAdapterHandler`: адаптер для интеграции с модулем `logging` позволяющий использовать пользовательские обработчики (`BaseHandler`, `StreamHandler` и т. д.) со стандартными логгерами Python
- `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

Expand All @@ -98,4 +98,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Первый релиз
- Initial release
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,31 @@
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tinylogging)
![Checks](https://github.com/HamletSargsyan/tinylogging/actions/workflows/check.yml/badge.svg)

## Установка
## 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
Expand All @@ -43,7 +42,7 @@ logger.handlers.add(file_handler)
logger.warning("This warning will be logged to both console and file.")
```

### Пользовательское форматирование
### Custom formatting

```python
from tinylogging import Formatter
Expand All @@ -53,18 +52,18 @@ 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 anyio
import asyncio
from tinylogging import AsyncLogger, AsyncFileHandler


Expand All @@ -80,9 +79,9 @@ async def main():


if __name__ == "__main__":
anyio.run(main)
asyncio.run(main)
```

## Лицензия
## License

Этот проект лицензирован под лицензией [MIT](https://github.com/HamletSargsyan/tiny-logging/blob/main/LICENSE).
This project is licensed under the [MIT License](https://github.com/HamletSargsyan/tinylogging/blob/main/LICENSE).
3 changes: 3 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# API reference

::: tinylogging
101 changes: 101 additions & 0 deletions docs/changelog.md
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
87 changes: 87 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# tinylogging

![GitHub License](https://img.shields.io/github/license/HamletSargsyan/tinylogging)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/HamletSargsyan/tinylogging)
![PyPI - Downloads](https://img.shields.io/pypi/dm/tinylogging)
![PyPI - Version](https://img.shields.io/pypi/v/tinylogging)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tinylogging)
![Checks](https://github.com/HamletSargsyan/tinylogging/actions/workflows/check.yml/badge.svg)

## 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).
Loading

0 comments on commit 33edb49

Please sign in to comment.