Skip to main content

log-decorator

Um decorador de logging flexível e poderoso para Python, construído sobre o Loguru.

Criado por Bruno Sardou

Características

  • Decorador de funções para logging automático
  • Filtragem hierárquica de níveis de log
  • Exibição colorida no console
  • Criação automática de diretórios de log
  • Registro em arquivo e console simultaneamente
  • Informações de contexto (usuário, arquivo)
  • Uso flexível (com ou sem parênteses)

Instalação

pip install log-decorator

Ou com Poetry:

poetry add log-decorator

Uso Básico

from log_decorator import log_decorator

# Uso básico (nível INFO padrão)
@log_decorator
def soma(a, b):
    return a + b

# Especificando um nível
@log_decorator(level="DEBUG")
def multiplica(a, b):
    return a * b

# Função que gera erro
@log_decorator(level="ERROR")
def divide(a, b):
    return a / b

# Usando as funções
soma(5, 3)       # Registra chamada e resultado no nível INFO
multiplica(4, 2)  # Registra chamada e resultado no nível DEBUG
divide(10, 0)     # Registra erro no nível ERROR

Níveis Disponíveis

  • TRACE (5)
  • DEBUG (10)
  • INFO (20)
  • SUCCESS (25)
  • WARNING (30)
  • ERROR (40)
  • CRITICAL (50)

Saída de Log

No console (colorido):

INFO | Executando 'soma' com args=(5, 3), kwargs={}
SUCCESS | Resultado de 'soma': 8

No arquivo de log (pasta logs/ no diretório do projeto):

2025-03-01T14:23:45.123456 | INFO | Executando 'soma' com args=(5, 3), kwargs={} | Usuário: joao | Arquivo: exemplo.py
2025-03-01T14:23:45.123498 | SUCCESS | Resultado de 'soma': 8 | Usuário: joao | Arquivo: exemplo.py

Licença

MIT

Metadata

Release files for bs-log-decorator 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for bs-log-decorator 0.1.0
File Interpreter ABI Platform Actions
bs_log_decorator-0.1.0-py3-none-any.whl Python 3 none any Details for bs_log_decorator-0.1.0-py3-none-any.whl

Release files / bs_log_decorator-0.1.0-py3-none-any.whl

Download URL bs_log_decorator-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07b05f5e11cb1d6aeff8025640421b31c19b11d7540e393931aa7d5e41c5c035
BLAKE2b-256 checksum
How to use checksums
da6c583b8bf13bf531dc16aa97b2b8940f36f23c11f0ee6167a16eb70c98779e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for bs-log-decorator 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page