Skip to main content

Python library for logging with colors and http status code.

Project description

Frexco PyLogger

Install


pip install frexco_pylogger

Configure


# main.py
from frexco_pylogger.functions import PyLogger

logger = PyLogger(appname="my_app")
logger.http(message="Uma mensagem http qualquer", status_code=200, data={"name": "Um nome qualquer", "age": 22})

2022-09-02 14:05:59 | [HTTP ] | Uma mensagem http qualquer | [STATUSCODE 200] | {'name': 'Um nome qualquer', 'age': 22}

Log Types


Tipo Description
error Informar sobre exceptions tratadas
warning Informar eventos ou estados potencialmente prejudicias ao programa
debug Acompanhar eventos ou estados do programa
info Descrever infos detalhadas sobre o estado do programa
http Informar dados de requests e responses feitas via http

Middlewares


django

# httpLogger.py
from frexco_pylogger.functions import PyLogger
from django.utils.deprecation import MiddlewareMixin


class HTTPLoggerMiddleware(MiddlewareMixin):

    def process_response(self, request, response):
        logger = PyLogger(appname="my_django_app")
        logger.http(message=f'{request.META.get("REMOTE_ADDR")} {request.method} {request.META.get("PATH_INFO")}',
                    status_code=response.status_code)

        return response
# setting.py

MIDDLEWARE = [
    ...,
    'app.utils.httpLogger.HTTPLoggerMiddleware' # path to your middleware file
]

Flask

# Your app setup file
from flask import Flask, request, Response
from frexco_pylogger.functions import PyLogger

app = Flask(__name__)
logger = PyLogger(appname="my_flask_app")

@app.after_request
def log_response(response: Response):
    logger.http(message=f'{request.remote_addr} {request.method} {request.path}',
                status_code=response.status_code)
    return response

Alert

# Seu arquivo de configuração de logger
from frexco_pylogger.functions import PyLogger

logger = PyLogger(appname="my_app_name", group="nome_do_grupo") # Ex: group="warehouse", Ex: group="consumer"

logger.error(message="Uma messagem de error qualquer",
            status_code=500, data={"name": "Um error"}) # Enviar alerta

logger.error(message="Uma messagem de error qualquer repetida",
            status_code=500, data={"name": "Um error"}, alert=False) # Não enviar alerta

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

fxc_logger-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

fxc_logger-1.0.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file fxc_logger-1.0.0.tar.gz.

File metadata

  • Download URL: fxc_logger-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for fxc_logger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 692f2b4888eafe62700fec240832101af67caa8aa32c2daf955f723ba6d492c2
MD5 c2d3f4ebedf2b521d24a6b106631ef00
BLAKE2b-256 dc239e10d6c5f8a1abae4dc4c2b78e0b9c77edb63911bfd7cbfee2063fbc7edc

See more details on using hashes here.

File details

Details for the file fxc_logger-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fxc_logger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for fxc_logger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 289c979e5c1ae5b57d86ad4a8aa69010616926800b4bfe13234ef38fea7c4dd5
MD5 dc6da610ff917aaacfe68d1191ec5438
BLAKE2b-256 3a5fe37e9c7cfac6fac52fc9d5e0ee8aa3b4b367e224dda74b8a4a9c2f9de1f0

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