Skip to content

API reference

tinylogging

AsyncLogger

__init__

__init__(name: str, level: Level = NOTSET, formatter: Formatter = Formatter(), handlers: set[BaseAsyncHandler] = set()) -> None

Initializes an asynchronous logger.

Parameters:

Name Type Description Default
name str

The name of the logger.

required
level Level

The logging level. Defaults to Level.NOTSET.

NOTSET
formatter Formatter

The formatter for log messages. Defaults to Formatter().

Formatter()
handlers set[BaseAsyncHandler]

A set of handlers for the logger. Defaults to an empty set.

set()

log async

log(message: str, level: Level) -> None

Logs a message at the specified level.

Parameters:

Name Type Description Default
message str

The message to log.

required
level Level

The level at which to log the message.

required

trace async

trace(message: str) -> None

Logs a message with TRACE level.

Parameters:

Name Type Description Default
message str

The message to log.

required

debug async

debug(message: str) -> None

Logs a message with DEBUG level.

Parameters:

Name Type Description Default
message str

The message to log.

required

info async

info(message: str) -> None

Logs a message with INFO level.

Parameters:

Name Type Description Default
message str

The message to log.

required

notice async

notice(message: str) -> None

Logs a message with NOTICE level.

Parameters:

Name Type Description Default
message str

The message to log.

required

warning async

warning(message: str) -> None

Logs a message with WARNING level.

Parameters:

Name Type Description Default
message str

The message to log.

required

error async

error(message: str) -> None

Logs a message with ERROR level.

Parameters:

Name Type Description Default
message str

The message to log.

required

critical async

critical(message: str) -> None

Logs a message with CRITICAL level.

Parameters:

Name Type Description Default
message str

The message to log.

required

enable

enable() -> None

Enables the logger.

disable

disable() -> None

Disables the logger.

AsyncFileHandler

Bases: BaseAsyncHandler

Asynchronous handler for writing log records to a file.

__init__

__init__(file_name: str, level: Level = NOTSET, formatter: Formatter = Formatter(colorize=False)) -> None

Initializes the AsyncFileHandler.

Parameters:

Name Type Description Default
file_name str

The name of the file to write log records to.

required
level Level

The logging level threshold for this handler.

NOTSET
formatter Formatter

The formatter instance to format log records.

Formatter(colorize=False)

emit async

emit(record: Record) -> None

Emit a log record to the file.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

AsyncStreamHandler

Bases: BaseAsyncHandler

Asynchronous handler for streaming log records.

__init__

__init__(formatter: Formatter = Formatter(), level: Level = NOTSET, stream: Optional[AsyncFile[str]] = None) -> None

Initializes the AsyncStreamHandler.

Parameters:

Name Type Description Default
formatter Formatter

The formatter instance to format log records.

Formatter()
level Level

The logging level threshold for this handler.

NOTSET
stream Optional[AsyncFile[str]]

The stream to write log records to.

None

emit async

emit(record: Record) -> None

Emit a log record to the stream.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

AsyncTelegramHandler

Bases: BaseAsyncHandler

Asynchronous handler for sending log records to a Telegram chat.

__init__

__init__(token: str, chat_id: int | str, message_thread_id: Optional[int] = None, ignore_errors: bool = False, **kwargs: Any) -> None

Initializes the AsyncTelegramHandler.

Parameters:

Name Type Description Default
token str

The Telegram bot token.

required
chat_id int | str

The chat ID to send log records to.

required
message_thread_id Optional[int]

The message thread ID (optional).

None
ignore_errors bool

Whether to ignore errors during sending.

False
**kwargs Any

Additional keyword arguments for the base handler.

{}

emit async

emit(record: Record) -> None

Emit a log record to the Telegram chat.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

BaseAsyncHandler

Bases: ABC

Base class for all async handlers.

__init__

__init__(formatter: Formatter = Formatter(), level: Level = NOTSET) -> None

Initializes the BaseAsyncHandler.

Parameters:

Name Type Description Default
formatter Formatter

The formatter instance to format log records.

Formatter()
level Level

The logging level threshold for this handler.

NOTSET

emit abstractmethod async

emit(record: Record) -> None

Emit a log record.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

Raises:

Type Description
NotImplementedError

This method should be overridden by subclasses.

handle async

handle(record: Record) -> None

Handle a log record if it meets the logging level threshold.

Parameters:

Name Type Description Default
record Record

The log record to be handled.

required

Formatter

__init__

__init__(time_format: str = '[%H:%M:%S]', template: str = '{time} | {level} | {relpath}:{line} | {message}', colorize: bool = True) -> None

Initializes the Formatter instance.

Parameters:

Name Type Description Default
time_format str

The format for the timestamp in log messages.

'[%H:%M:%S]'
template str

The template for formatting log messages.

'{time} | {level} | {relpath}:{line} | {message}'
colorize bool

Whether to colorize the log messages.

True

format

format(record: Record) -> str

Formats a log record.

Parameters:

Name Type Description Default
record Record

The log record to format.

required

Returns:

Name Type Description
str str

The formatted log message.

Level

Bases: IntEnum

Enumeration for logging levels.

Attributes:

Name Type Description
NOTSET

No level set.

TRACE

Trace level for detailed debugging.

DEBUG

Debug level for general debugging.

INFO

Informational messages.

NOTICE

Notice level for normal but significant conditions.

WARNING

Warning level for potentially harmful situations.

ERROR

Error level for error events.

CRITICAL

Critical level for severe error events.

Record dataclass

Represents a log record.

Attributes:

Name Type Description
message str

The log message.

level Level

The log level.

name str

The name of the logger.

time datetime

The time the log record was created.

filename str

The name of the file where the log record was created.

line int

The line number in the file where the log record was created.

function str

The function name where the log record was created.

basename property

basename: str

Gets the base name of the file where the log record was created.

Returns:

Name Type Description
str str

The base name of the file.

relpath property

relpath: str

Gets the relative path of the file where the log record was created.

Returns:

Name Type Description
str str

The relative path of the file.

__post_init__

__post_init__() -> None

Initializes additional attributes after the dataclass is created.

Raises:

Type Description
RuntimeError

If the stack frame cannot be retrieved.

to_dict

to_dict() -> dict[str, Any]

Converts the log record to a dictionary.

Returns:

Name Type Description
dict dict[str, Any]

A dictionary representation of the log record.

Logger

__init__

__init__(name: str, level: Level = NOTSET, formatter: Formatter = Formatter(), handlers: set[BaseHandler] = set()) -> None

Initializes a new Logger instance.

Parameters:

Name Type Description Default
name str

The name of the logger.

required
level Level

The logging level. Defaults to Level.NOTSET.

NOTSET
formatter Formatter

The formatter for log messages. Defaults to Formatter().

Formatter()
handlers set[BaseHandler]

A set of handlers for the logger. Defaults to an empty set.

set()

log

log(message: str, level: Level) -> None

Logs a message with the specified logging level.

Parameters:

Name Type Description Default
message str

The message to log.

required
level Level

The logging level for the message.

required

trace

trace(message: str) -> None

Logs a message with TRACE level.

Parameters:

Name Type Description Default
message str

The message to log.

required

debug

debug(message: str) -> None

Logs a message with DEBUG level.

Parameters:

Name Type Description Default
message str

The message to log.

required

info

info(message: str) -> None

Logs a message with INFO level.

Parameters:

Name Type Description Default
message str

The message to log.

required

notice

notice(message: str) -> None

Logs a message with NOTICE level.

Parameters:

Name Type Description Default
message str

The message to log.

required

warning

warning(message: str) -> None

Logs a message with WARNING level.

Parameters:

Name Type Description Default
message str

The message to log.

required

error

error(message: str) -> None

Logs a message with ERROR level.

Parameters:

Name Type Description Default
message str

The message to log.

required

critical

critical(message: str) -> None

Logs a message with CRITICAL level.

Parameters:

Name Type Description Default
message str

The message to log.

required

enable

enable() -> None

Enables the logger.

disable

disable() -> None

Disables the logger.

BaseHandler

Bases: ABC

Abstract base class for all handlers.

Parameters:

Name Type Description Default
formatter Formatter

Formatter instance to format the log records.

Formatter()
level Level

Logging level for the handler.

NOTSET

emit abstractmethod

emit(record: Record) -> None

Emit a log record.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

handle

handle(record: Record) -> None

Handle a log record.

Parameters:

Name Type Description Default
record Record

The log record to be handled.

required

FileHandler

Bases: BaseHandler

Handler for writing log records to a file.

Parameters:

Name Type Description Default
file_name str

Name of the file to write log records to.

required
level Level

Logging level for the handler.

NOTSET
formatter Formatter

Formatter instance to format the log records.

Formatter(colorize=False)

emit

emit(record: Record) -> None

Emit a log record to the file.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

LoggingAdapterHandler

Bases: Handler

Adapter handler to integrate with the standard logging module.

Parameters:

Name Type Description Default
handler BaseHandler

Custom handler to delegate log records to.

required

emit

emit(record: LogRecord) -> None

Emit a log record using the custom handler.

Parameters:

Name Type Description Default
record LogRecord

The log record to be emitted.

required

StreamHandler

Bases: BaseHandler

Handler for streaming log records to a stream.

Parameters:

Name Type Description Default
formatter Formatter

Formatter instance to format the log records.

Formatter()
level Level

Logging level for the handler.

NOTSET
stream Optional[TextIO]

Stream to write log records to.

None

emit

emit(record: Record) -> None

Emit a log record to the stream.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

TelegramHandler

Bases: BaseHandler

Handler for sending log records to a Telegram chat.

Parameters:

Name Type Description Default
token str

Telegram bot token.

required
chat_id int | str

Chat ID to send messages to.

required
ignore_errors bool

Whether to ignore errors when sending messages.

False
message_thread_id Optional[int]

ID of the message thread.

None
**kwargs Any

Additional keyword arguments for the base handler.

{}

emit

emit(record: Record) -> None

Emit a log record to the Telegram chat.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

aio

AsyncFileHandler

Bases: BaseAsyncHandler

Asynchronous handler for writing log records to a file.

__init__
__init__(file_name: str, level: Level = NOTSET, formatter: Formatter = Formatter(colorize=False)) -> None

Initializes the AsyncFileHandler.

Parameters:

Name Type Description Default
file_name str

The name of the file to write log records to.

required
level Level

The logging level threshold for this handler.

NOTSET
formatter Formatter

The formatter instance to format log records.

Formatter(colorize=False)
emit async
emit(record: Record) -> None

Emit a log record to the file.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

AsyncTelegramHandler

Bases: BaseAsyncHandler

Asynchronous handler for sending log records to a Telegram chat.

__init__
__init__(token: str, chat_id: int | str, message_thread_id: Optional[int] = None, ignore_errors: bool = False, **kwargs: Any) -> None

Initializes the AsyncTelegramHandler.

Parameters:

Name Type Description Default
token str

The Telegram bot token.

required
chat_id int | str

The chat ID to send log records to.

required
message_thread_id Optional[int]

The message thread ID (optional).

None
ignore_errors bool

Whether to ignore errors during sending.

False
**kwargs Any

Additional keyword arguments for the base handler.

{}
emit async
emit(record: Record) -> None

Emit a log record to the Telegram chat.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

BaseAsyncHandler

Bases: ABC

Base class for all async handlers.

__init__
__init__(formatter: Formatter = Formatter(), level: Level = NOTSET) -> None

Initializes the BaseAsyncHandler.

Parameters:

Name Type Description Default
formatter Formatter

The formatter instance to format log records.

Formatter()
level Level

The logging level threshold for this handler.

NOTSET
emit abstractmethod async
emit(record: Record) -> None

Emit a log record.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

Raises:

Type Description
NotImplementedError

This method should be overridden by subclasses.

handle async
handle(record: Record) -> None

Handle a log record if it meets the logging level threshold.

Parameters:

Name Type Description Default
record Record

The log record to be handled.

required

AsyncLogger

__init__
__init__(name: str, level: Level = NOTSET, formatter: Formatter = Formatter(), handlers: set[BaseAsyncHandler] = set()) -> None

Initializes an asynchronous logger.

Parameters:

Name Type Description Default
name str

The name of the logger.

required
level Level

The logging level. Defaults to Level.NOTSET.

NOTSET
formatter Formatter

The formatter for log messages. Defaults to Formatter().

Formatter()
handlers set[BaseAsyncHandler]

A set of handlers for the logger. Defaults to an empty set.

set()
log async
log(message: str, level: Level) -> None

Logs a message at the specified level.

Parameters:

Name Type Description Default
message str

The message to log.

required
level Level

The level at which to log the message.

required
trace async
trace(message: str) -> None

Logs a message with TRACE level.

Parameters:

Name Type Description Default
message str

The message to log.

required
debug async
debug(message: str) -> None

Logs a message with DEBUG level.

Parameters:

Name Type Description Default
message str

The message to log.

required
info async
info(message: str) -> None

Logs a message with INFO level.

Parameters:

Name Type Description Default
message str

The message to log.

required
notice async
notice(message: str) -> None

Logs a message with NOTICE level.

Parameters:

Name Type Description Default
message str

The message to log.

required
warning async
warning(message: str) -> None

Logs a message with WARNING level.

Parameters:

Name Type Description Default
message str

The message to log.

required
error async
error(message: str) -> None

Logs a message with ERROR level.

Parameters:

Name Type Description Default
message str

The message to log.

required
critical async
critical(message: str) -> None

Logs a message with CRITICAL level.

Parameters:

Name Type Description Default
message str

The message to log.

required
enable
enable() -> None

Enables the logger.

disable
disable() -> None

Disables the logger.

handlers

BaseAsyncHandler

Bases: ABC

Base class for all async handlers.

__init__
__init__(formatter: Formatter = Formatter(), level: Level = NOTSET) -> None

Initializes the BaseAsyncHandler.

Parameters:

Name Type Description Default
formatter Formatter

The formatter instance to format log records.

Formatter()
level Level

The logging level threshold for this handler.

NOTSET
emit abstractmethod async
emit(record: Record) -> None

Emit a log record.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

Raises:

Type Description
NotImplementedError

This method should be overridden by subclasses.

handle async
handle(record: Record) -> None

Handle a log record if it meets the logging level threshold.

Parameters:

Name Type Description Default
record Record

The log record to be handled.

required
AsyncStreamHandler

Bases: BaseAsyncHandler

Asynchronous handler for streaming log records.

__init__
__init__(formatter: Formatter = Formatter(), level: Level = NOTSET, stream: Optional[AsyncFile[str]] = None) -> None

Initializes the AsyncStreamHandler.

Parameters:

Name Type Description Default
formatter Formatter

The formatter instance to format log records.

Formatter()
level Level

The logging level threshold for this handler.

NOTSET
stream Optional[AsyncFile[str]]

The stream to write log records to.

None
emit async
emit(record: Record) -> None

Emit a log record to the stream.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required
AsyncFileHandler

Bases: BaseAsyncHandler

Asynchronous handler for writing log records to a file.

__init__
__init__(file_name: str, level: Level = NOTSET, formatter: Formatter = Formatter(colorize=False)) -> None

Initializes the AsyncFileHandler.

Parameters:

Name Type Description Default
file_name str

The name of the file to write log records to.

required
level Level

The logging level threshold for this handler.

NOTSET
formatter Formatter

The formatter instance to format log records.

Formatter(colorize=False)
emit async
emit(record: Record) -> None

Emit a log record to the file.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required
AsyncTelegramHandler

Bases: BaseAsyncHandler

Asynchronous handler for sending log records to a Telegram chat.

__init__
__init__(token: str, chat_id: int | str, message_thread_id: Optional[int] = None, ignore_errors: bool = False, **kwargs: Any) -> None

Initializes the AsyncTelegramHandler.

Parameters:

Name Type Description Default
token str

The Telegram bot token.

required
chat_id int | str

The chat ID to send log records to.

required
message_thread_id Optional[int]

The message thread ID (optional).

None
ignore_errors bool

Whether to ignore errors during sending.

False
**kwargs Any

Additional keyword arguments for the base handler.

{}
emit async
emit(record: Record) -> None

Emit a log record to the Telegram chat.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

formatter

Formatter

__init__
__init__(time_format: str = '[%H:%M:%S]', template: str = '{time} | {level} | {relpath}:{line} | {message}', colorize: bool = True) -> None

Initializes the Formatter instance.

Parameters:

Name Type Description Default
time_format str

The format for the timestamp in log messages.

'[%H:%M:%S]'
template str

The template for formatting log messages.

'{time} | {level} | {relpath}:{line} | {message}'
colorize bool

Whether to colorize the log messages.

True
format
format(record: Record) -> str

Formats a log record.

Parameters:

Name Type Description Default
record Record

The log record to format.

required

Returns:

Name Type Description
str str

The formatted log message.

helpers

TelegramFormatter

Bases: Formatter

__init__
__init__(time_format: str = '%H:%M:%S')

Initializes the TelegramFormatter with a specific time format and template.

Parameters:

Name Type Description Default
time_format str

The format string for formatting the time. Defaults to "%H:%M:%S".

'%H:%M:%S'
format
format(record: Record) -> str

Formats a log record into a string suitable for Telegram.

Parameters:

Name Type Description Default
record Record

The log record to format.

required

Returns:

Name Type Description
str str

The formatted log record as a string.

level

Level

Bases: IntEnum

Enumeration for logging levels.

Attributes:

Name Type Description
NOTSET

No level set.

TRACE

Trace level for detailed debugging.

DEBUG

Debug level for general debugging.

INFO

Informational messages.

NOTICE

Notice level for normal but significant conditions.

WARNING

Warning level for potentially harmful situations.

ERROR

Error level for error events.

CRITICAL

Critical level for severe error events.

record

Record dataclass

Represents a log record.

Attributes:

Name Type Description
message str

The log message.

level Level

The log level.

name str

The name of the logger.

time datetime

The time the log record was created.

filename str

The name of the file where the log record was created.

line int

The line number in the file where the log record was created.

function str

The function name where the log record was created.

basename property
basename: str

Gets the base name of the file where the log record was created.

Returns:

Name Type Description
str str

The base name of the file.

relpath property
relpath: str

Gets the relative path of the file where the log record was created.

Returns:

Name Type Description
str str

The relative path of the file.

__post_init__
__post_init__() -> None

Initializes additional attributes after the dataclass is created.

Raises:

Type Description
RuntimeError

If the stack frame cannot be retrieved.

to_dict
to_dict() -> dict[str, Any]

Converts the log record to a dictionary.

Returns:

Name Type Description
dict dict[str, Any]

A dictionary representation of the log record.

sync

Formatter

__init__
__init__(time_format: str = '[%H:%M:%S]', template: str = '{time} | {level} | {relpath}:{line} | {message}', colorize: bool = True) -> None

Initializes the Formatter instance.

Parameters:

Name Type Description Default
time_format str

The format for the timestamp in log messages.

'[%H:%M:%S]'
template str

The template for formatting log messages.

'{time} | {level} | {relpath}:{line} | {message}'
colorize bool

Whether to colorize the log messages.

True
format
format(record: Record) -> str

Formats a log record.

Parameters:

Name Type Description Default
record Record

The log record to format.

required

Returns:

Name Type Description
str str

The formatted log message.

BaseHandler

Bases: ABC

Abstract base class for all handlers.

Parameters:

Name Type Description Default
formatter Formatter

Formatter instance to format the log records.

Formatter()
level Level

Logging level for the handler.

NOTSET
emit abstractmethod
emit(record: Record) -> None

Emit a log record.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required
handle
handle(record: Record) -> None

Handle a log record.

Parameters:

Name Type Description Default
record Record

The log record to be handled.

required

FileHandler

Bases: BaseHandler

Handler for writing log records to a file.

Parameters:

Name Type Description Default
file_name str

Name of the file to write log records to.

required
level Level

Logging level for the handler.

NOTSET
formatter Formatter

Formatter instance to format the log records.

Formatter(colorize=False)
emit
emit(record: Record) -> None

Emit a log record to the file.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

LoggingAdapterHandler

Bases: Handler

Adapter handler to integrate with the standard logging module.

Parameters:

Name Type Description Default
handler BaseHandler

Custom handler to delegate log records to.

required
emit
emit(record: LogRecord) -> None

Emit a log record using the custom handler.

Parameters:

Name Type Description Default
record LogRecord

The log record to be emitted.

required

TelegramHandler

Bases: BaseHandler

Handler for sending log records to a Telegram chat.

Parameters:

Name Type Description Default
token str

Telegram bot token.

required
chat_id int | str

Chat ID to send messages to.

required
ignore_errors bool

Whether to ignore errors when sending messages.

False
message_thread_id Optional[int]

ID of the message thread.

None
**kwargs Any

Additional keyword arguments for the base handler.

{}
emit
emit(record: Record) -> None

Emit a log record to the Telegram chat.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required

Logger

__init__
__init__(name: str, level: Level = NOTSET, formatter: Formatter = Formatter(), handlers: set[BaseHandler] = set()) -> None

Initializes a new Logger instance.

Parameters:

Name Type Description Default
name str

The name of the logger.

required
level Level

The logging level. Defaults to Level.NOTSET.

NOTSET
formatter Formatter

The formatter for log messages. Defaults to Formatter().

Formatter()
handlers set[BaseHandler]

A set of handlers for the logger. Defaults to an empty set.

set()
log
log(message: str, level: Level) -> None

Logs a message with the specified logging level.

Parameters:

Name Type Description Default
message str

The message to log.

required
level Level

The logging level for the message.

required
trace
trace(message: str) -> None

Logs a message with TRACE level.

Parameters:

Name Type Description Default
message str

The message to log.

required
debug
debug(message: str) -> None

Logs a message with DEBUG level.

Parameters:

Name Type Description Default
message str

The message to log.

required
info
info(message: str) -> None

Logs a message with INFO level.

Parameters:

Name Type Description Default
message str

The message to log.

required
notice
notice(message: str) -> None

Logs a message with NOTICE level.

Parameters:

Name Type Description Default
message str

The message to log.

required
warning
warning(message: str) -> None

Logs a message with WARNING level.

Parameters:

Name Type Description Default
message str

The message to log.

required
error
error(message: str) -> None

Logs a message with ERROR level.

Parameters:

Name Type Description Default
message str

The message to log.

required
critical
critical(message: str) -> None

Logs a message with CRITICAL level.

Parameters:

Name Type Description Default
message str

The message to log.

required
enable
enable() -> None

Enables the logger.

disable
disable() -> None

Disables the logger.

handlers

BaseHandler

Bases: ABC

Abstract base class for all handlers.

Parameters:

Name Type Description Default
formatter Formatter

Formatter instance to format the log records.

Formatter()
level Level

Logging level for the handler.

NOTSET
emit abstractmethod
emit(record: Record) -> None

Emit a log record.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required
handle
handle(record: Record) -> None

Handle a log record.

Parameters:

Name Type Description Default
record Record

The log record to be handled.

required
StreamHandler

Bases: BaseHandler

Handler for streaming log records to a stream.

Parameters:

Name Type Description Default
formatter Formatter

Formatter instance to format the log records.

Formatter()
level Level

Logging level for the handler.

NOTSET
stream Optional[TextIO]

Stream to write log records to.

None
emit
emit(record: Record) -> None

Emit a log record to the stream.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required
FileHandler

Bases: BaseHandler

Handler for writing log records to a file.

Parameters:

Name Type Description Default
file_name str

Name of the file to write log records to.

required
level Level

Logging level for the handler.

NOTSET
formatter Formatter

Formatter instance to format the log records.

Formatter(colorize=False)
emit
emit(record: Record) -> None

Emit a log record to the file.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required
LoggingAdapterHandler

Bases: Handler

Adapter handler to integrate with the standard logging module.

Parameters:

Name Type Description Default
handler BaseHandler

Custom handler to delegate log records to.

required
emit
emit(record: LogRecord) -> None

Emit a log record using the custom handler.

Parameters:

Name Type Description Default
record LogRecord

The log record to be emitted.

required
TelegramHandler

Bases: BaseHandler

Handler for sending log records to a Telegram chat.

Parameters:

Name Type Description Default
token str

Telegram bot token.

required
chat_id int | str

Chat ID to send messages to.

required
ignore_errors bool

Whether to ignore errors when sending messages.

False
message_thread_id Optional[int]

ID of the message thread.

None
**kwargs Any

Additional keyword arguments for the base handler.

{}
emit
emit(record: Record) -> None

Emit a log record to the Telegram chat.

Parameters:

Name Type Description Default
record Record

The log record to be emitted.

required