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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tinylogging-3.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-47-generic

File hashes

Hashes for tinylogging-3.1.0.tar.gz
Algorithm Hash digest
SHA256 aefb20f7c95c132b5d2ca374d3145bbc09c0dbfca709d66a7365003372b037c9
MD5 ab705911c88352c8d45177991e774d34
BLAKE2b-256 f155f20cf272a4c7a98a5252b25dee83a1950b1c6a916b39b8879bf98003285e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tinylogging-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-47-generic

File hashes

Hashes for tinylogging-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0303a6f0857b45e25096f398ba01b0bd36d20f778bdd7ea0783dafe35aeeb1c7
MD5 0af538022501c988674ddb9f7fd90da1
BLAKE2b-256 7075931872d804544679004f8ffffc3e40a3ce27cc572b5b153b3bb09cb32e87

See more details on using hashes here.

Supported by

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