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="myapp")
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="myDjangoApp")
logger.http(f'{request.META.get("REMOTE_ADDR")} {request.method} {request.META.get("PATH_INFO")}', {"status": 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="MyFlaskApp")
@app.after_request
def log_response(response: Response):
logger.http(f'{request.remote_addr} {request.method} {request.path}', {
"status": response.status_code})
return response
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.0.1.tar.gz
(3.1 kB
view details)
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file frexco_pylogger-0.0.1.tar.gz.
File metadata
- Download URL: frexco_pylogger-0.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71135ecdf00d2154786b8481cc50df118b949eb446655dc219610acf6a9f58ea
|
|
| MD5 |
0c1ac04bf559783c5260c8711b946fd1
|
|
| BLAKE2b-256 |
fdf753ff37c69a0048b352eae839835222760ce6185e89fca3c6f6d8ef4badbd
|
File details
Details for the file frexco_pylogger-0.0.1-py3.10.egg.
File metadata
- Download URL: frexco_pylogger-0.0.1-py3.10.egg
- Upload date:
- Size: 7.6 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
200bc1d8edab654e7ce92d52730dee573696f7c56c05bb2b35144f2cf9620d8c
|
|
| MD5 |
7dfb93576277743c528346c9e5d73e29
|
|
| BLAKE2b-256 |
db7a650344721d832e1c6767e8fe606db5d43fe5c0a755cd06f1dd0b5e6ee997
|
File details
Details for the file frexco_pylogger-0.0.1-py3-none-any.whl.
File metadata
- Download URL: frexco_pylogger-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beaf331ce1636c14f9a2d2bd1fe4e53a38a07c9782e6cf42fa4ff59dba6ca174
|
|
| MD5 |
a34ef4daf9e5c39fee5888412be6c24b
|
|
| BLAKE2b-256 |
fa112f753747adbc1f026cc93a2ee64b74fcb6ffbcd928f2c0befee8e59ffc1c
|