No project description provided
Project description
tinylogging
Установка
pip install tinylogging
Использование
Создание нового логгера
from tinylogging import Logger, Level
logger = Logger(name="my_logger", level=Level.DEBUG)
Логирование сообщений
logger.info("This is an info message.")
logger.error("This is an error message.")
logger.debug("This is a debug message.")
Логирования в файл
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.")
Пользовательское форматирование
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.")
Отключение логирования
logger.disable()
logger.info("This message will not be logged.")
logger.enable()
Поддержка асинхронности
import anyio
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__":
anyio.run(main)
Лицензия
Этот проект лицензирован под лицензией MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tinylogging-4.0.0.tar.gz
(5.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tinylogging-4.0.0.tar.gz.
File metadata
- Download URL: tinylogging-4.0.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.12.4-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
802109d1ca26e2e427fc6aeddc30b6a549a77be9a2a55af0a735470cd030cc25
|
|
| MD5 |
022b93d1afe433c3536f178dee43114f
|
|
| BLAKE2b-256 |
a61d054355351e4018be901676ed9aa9d10a79c5e03766077c03b4f10a7fc4b0
|
File details
Details for the file tinylogging-4.0.0-py3-none-any.whl.
File metadata
- Download URL: tinylogging-4.0.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.12.4-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2e523eebac944917c64f172da6d807f16897b8f4c94ee86d851e0effb9a7e47
|
|
| MD5 |
97a6b7447008e277316074880770a129
|
|
| BLAKE2b-256 |
8adfdf56bcf41fc314ca7ce76521e5327fb13750b10e0cd4edc138cf8f4ab9cc
|