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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tinylogging-3.2.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-48-generic

File hashes

Hashes for tinylogging-3.2.0.tar.gz
Algorithm Hash digest
SHA256 c8012d2416c14bcb1f90eaf20a43f0824dc1a4df97c8c70acbbd1d1c49d1ad95
MD5 9918b8e75297eb408b98ebd97c6bbccc
BLAKE2b-256 e3f881d1b7cd7ceca534fed6b79d24cd6695cea43780df2be4157c4c1eead8c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tinylogging-3.2.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-48-generic

File hashes

Hashes for tinylogging-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c42b881c73a066f43af1fbf5cf036e2dc9331819219833910a7de67d892dd2e1
MD5 33d7b5fe0e4d52619988f124350ae5c1
BLAKE2b-256 ed36dfcf75744c7c9821d3253968b488e099aeaa4324b1f901e84dab56b54c9d

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