Package: logoverr
DocumentationIn order to use this logger, all you need to do is to import it in your machine using:pip install logoverAfter installation here comes the configuration part, one need to do in order to use this logger in flask application. There are basically 5 configurable parameters are there in the logger named:1.buffer size2.buffer time-out time3.project id(from viasocket)4.auth key(from viasocket)5.END_POINT_TO_SIMULATE_DB(this the end point, from where logger gets two parameters called includes(it is list of routes whose logges to be send)and second is levels(it is list of logging levels whose logs to be send))Note: Property number 3, 4 and 5 are mandatory to set, otherwise you will get error.Refer below code snippet to configure above parameters in your flask application:logover.set_buffer_size(2)
logover.set_buffer_timeout(2)
logover.set_project_id('szfb72eUt5eRaWxaXE6J')
logover.set_auth_key('ucdPnQgLqT2GPsquD9xv')
logover.set_END_POINT_TO_SIMULATE_DB("http://127.0.0.1:9000/")WAIT A MIN!!!Before you move further, please make sure that you have a endpoint which returns two lists, includes and levels.For your reference, below is sample application which does the required function. For now you can create a app "simulating_db.py" in your system and paste the below code.from flask import Flask,jsonify, request
import jsonapp = Flask(name)@app.route("/", methods=["POST","GET"])
def setName():
if request.method == 'GET':
includes = ['/login']
levels=['WARN']
res = [includes,levels]
print(res)
return jsonify(res)We are not yet done with this step, before running main application, start this app:go to path where you created above file->run "set flask_app=simulating_db.py"run "set flask_env=development"run "flask run --port=9000"hasshh!! we are done with this. Lets move forward.After successfully completing above step,lets move to the core functionality of our logger i.e logging request and response data. For this copy and paste below code in the end of your flask application.@app.before_request
def start_timer():
    print('before every request')
    g.start = time.time()

@app.after_request
def fun(response):
    logover.log_request(response)
    return responseHeads up!! We are done.logger does not stop serving here only, it has something more for you. Apart from request and response logs, if you want to log info or error or warning logs then for this logger has three more methods. you can use this methods anywhere you want.for reference see below snippet.info() methodlogover.info('Information message')warn() methodlogover.warn('Warning!!')error() methodlogover.error('Opps!!Error!')we are almost done now...but for better understanding about how to use this logger, have a look at complete flask application which uses this logger.import datetime
import time
import json

import pylogger

from flask import Flask, g, request


logover.set_buffer_size(2)
logover.set_buffer_timeout(2)
logover.set_project_id('szfb72eUt5eRaWxaXE6J')
logover.set_auth_key('ucdPnQgLqT2GPsquD9xv')
logover.set_END_POINT_TO_SIMULATE_DB("http://127.0.0.1:9000/")

app = Flask(__name__)


@app.route("/")
def index():
    logover.info('inside index')
    print("index is running!")
    return "Hello world"

@app.route("/login")
def login():
    logover.error('inside login')
    print("on login page!")
    return "login page"

@app.route("/register")
def register():
    logover.warn('inside register')
    print("on register page!")
    return "register page"

@app.route("/logout")
def logout():
    logover.info('inside logout')
    print("on logout page!")
    return "logout page"


if __name__ == "__main__":
    app.run()



@app.before_request
def start_timer():
    print('before every request')
    g.start = time.time()


@app.after_request
def fun(response):
    logover.log_request(response)
    return response