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.0.tar.gz (4.3 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.0-py3.10.egg (7.8 kB view details)

Uploaded Egg

File details

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

File metadata

  • Download URL: frexco_pylogger-0.2.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for frexco_pylogger-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c105d79b209ec837470c22b57427861a5745179d75b2cf80851413d1ec8cc6bc
MD5 da595f5243b975d49c295cc0ca4e548c
BLAKE2b-256 8cd15dd07df47d2ca70cb6e99ec01540f284e52e7d53da51fab287513e7dac3e

See more details on using hashes here.

File details

Details for the file frexco_pylogger-0.2.0-py3.10.egg.

File metadata

  • Download URL: frexco_pylogger-0.2.0-py3.10.egg
  • Upload date:
  • Size: 7.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for frexco_pylogger-0.2.0-py3.10.egg
Algorithm Hash digest
SHA256 9d428b013b42b468b3bad5ef627dbcc99c2f888a666756127d52c8c3024c737f
MD5 286f655060df6dc31ea4a66c55e97417
BLAKE2b-256 4febba3b7c25d9ffd5bea83a397787f35f0c188002d48ca48f80b017a796c9a6

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