Skip to main content

No project description provided

Project description

tinylogging

GitHub License GitHub commit activity PyPI - Downloads PyPI - Version

Установка

pip install tinylogging

Использование

Create a Logger

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

Uploaded Source

Built Distribution

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

tinylogging-3.3.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tinylogging-3.3.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.8 Linux/6.12.4-arch1-1

File hashes

Hashes for tinylogging-3.3.0.tar.gz
Algorithm Hash digest
SHA256 3fc51cdf358707b8c1dfd9681071a37219986c649e9370145762a0daa7a79325
MD5 dfc1efbb827b33b9462101daa5f02bd2
BLAKE2b-256 d92246c4edf2bf2c7aab3c777facdf5ad42158466af3580ec8e16758e4bb28bd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tinylogging-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e9c524d73658a308a7505f910c1b84e410bed66d844de2fa328cd12cc6e91cf
MD5 00e50dabe7cef86a383455c5f38da578
BLAKE2b-256 82d621866af7807dbbda2e1a707688a2f52489a02ffddc7a408b3c4488f2ce11

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