Skip to content

Commit

Permalink
правки
Browse files Browse the repository at this point in the history
  • Loading branch information
HamletSargsyan committed Jan 17, 2025
1 parent 6176300 commit de1ed18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Добавлена поддержка эмодзи для уровней логов в `Formatter`

### Changed

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

## [4.0.0] - 2025-01-14

### Added
Expand Down
3 changes: 2 additions & 1 deletion src/tinylogging/aio/handlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from abc import ABC, abstractmethod
from typing import Optional

import httpx
from anyio import AsyncFile, open_file
Expand Down Expand Up @@ -39,7 +40,7 @@ def __init__(
self,
formatter: Formatter = Formatter(),
level: Level = Level.NOTSET,
stream: AsyncFile[str] | None = None,
stream: Optional[AsyncFile[str]] = None,
) -> None:
super().__init__(formatter=formatter, level=level)
self.stream = stream or AsyncFile(sys.stdout)
Expand Down
2 changes: 1 addition & 1 deletion src/tinylogging/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TelegramFormatter(Formatter):
def __init__(self, time_format: str = "%H:%M:%S"):
template = (
"<b>{level}</b>\n\n"
"<b>{emoji} {level}</b>\n\n"
"<b>time:</b> <code>{time}</code>\n"
"<b>logger:</b> <code>{name}</code>\n"
"<b>file:</b> <code>{relpath}</code>\n"
Expand Down
4 changes: 2 additions & 2 deletions src/tinylogging/sync/handlers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import sys
from abc import ABC, abstractmethod
from typing import TextIO
from typing import TextIO, Optional

import httpx

Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(
self,
formatter: Formatter = Formatter(),
level: Level = Level.NOTSET,
stream: TextIO | None = None,
stream: Optional[TextIO] = None,
) -> None:
super().__init__(formatter=formatter, level=level)
self.stream = stream or sys.stdout # type: TextIO
Expand Down

0 comments on commit de1ed18

Please sign in to comment.