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

frexco_pylogger-0.2.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

frexco_pylogger-0.2.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file frexco_pylogger-0.2.1.tar.gz.

File metadata

  • Download URL: frexco_pylogger-0.2.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for frexco_pylogger-0.2.1.tar.gz
Algorithm Hash digest
SHA256 93ec61efd603aac723622db427f165b0bf4d933dd6577ceb27b7fa1687f97067
MD5 9e40ce9f577307dd737cccefe5f547a6
BLAKE2b-256 b68125778d84673fc226d52fc55613969c403e5c5e61cbd13cde6be5f7796a6d

See more details on using hashes here.

File details

Details for the file frexco_pylogger-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for frexco_pylogger-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e90f132ce63a58b7578794c1d30f39d9a32a7fa30de707f861c6e12c9881219
MD5 3f6a6f42ae3fc5244e479afd773b9fd7
BLAKE2b-256 c7cfac94dd501480822b2bdabfba878f6e6c5bf3b7ae1d986bd1194f4a56965e

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