Skip to main content

A simple lib for postgres logging

Project description

Save logs records in postgres.
Log record can contain any num of fields.
Logs format in the table:
data TEXT
{"field1": "value", "field2": "value", "field3": "value"}

# example of use
from pglogs.models import Pg, LogRecord

pg = Pg('pglogs', 'pglogs_user', '', 'qwerty')

log = LogRecord(pg)
log.set_field('chef_request', """'{}[[[]dfdfd''']]--pdfdfdfdfd\\SOME HACKER BEEN HERE}'""")
log.set_field('proxy_response', """dfdg'gfgfd'g'dsgd\'gfsdfg\'gdf/dgfd/fdg/f/dgd'\"\\''''""")

# example of use for log Flask requests
from pglogs.models import Pg, LogRecord
from pglogs.utils import pack_request_log
from flask import Flask, request, g

app = Flask(__name__)
pg = Pg('pglogs', 'pglogs_user', '', 'qwerty')

def init_request_log():
if not hasattr(g, 'log'):
g.log = LogRecord(pg)

def hello():
return "Hello World!"

if __name__ == "__main__":

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pglogs-0.1.5.tar.gz (5.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page