Skip to main content

No project description provided

Project description

tinylogging

GitHub License GitHub commit activity PyPI - Downloads PyPI - Version Checks

Установка

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


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.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tinylogging-4.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file tinylogging-4.1.0.tar.gz.

File metadata

  • Download URL: tinylogging-4.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.12.9-arch1-1

File hashes

Hashes for tinylogging-4.1.0.tar.gz
Algorithm Hash digest
SHA256 5f35bc354ddc00b3141d49dedfdfc836a5c7274b195ac67f2d37c88fb711c0b1
MD5 6e305e977b008e1fe896d6e665bf99d1
BLAKE2b-256 83d19fe30c5f2ce4b1f0f9ab8f5f28173b58de59678f8c846df6c40bbd24fe7e

See more details on using hashes here.

File details

Details for the file tinylogging-4.1.0-py3-none-any.whl.

File metadata

  • Download URL: tinylogging-4.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.12.9-arch1-1

File hashes

Hashes for tinylogging-4.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d1f0b4f2bc58efc547e836e4cd1f56f1febcea961b780fcf444958a1c99b9c0
MD5 243f4ebba2d52f3891eb0404de209fb9
BLAKE2b-256 171d4d55905cb5325505e12b4ebc285c36cc1846111ca376276073bf295c2a65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page