Skip to content

balanced/frl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FRL Flask Requests Logger

Build Status Latest Version Downloads Supported Python versions License

A request logger for requests and responses from the requests and flask libraries that logs in a standard format

{
   "meta":{

   },
   "request":{
      "headers":[
         [
            "Host",
            "localhost"
         ],
         [
            "Content-Length",
            "0"
         ],
         [
            "Content-Type",
            ""
         ]
      ],
      "url":"http://localhost/",
      "method":"GET",
      "payload": null
   },
   "response":{
      "status":"200 OK",
      "headers":[
         [
            "Content-Type",
            "text/html; charset=utf-8"
         ],
         [
            "Content-Length",
            "12"
         ]
      ],
      "data":"Hello World!"
   }
}

Configure flask

class FlaskApp(flask.Flask):

    def log_it(self, response):
        logger.log(response)
        return response

logger = frl.server.ServerRequestLogger(
    'logger-name',
    ['card_number', 'password']
)

app = FlaskApp(__name__)
app.after_request(app.log_it)

Configure requests

logger = frl.client.ClientRequestLogger(
    'logger-name',
    ['card_number', 'password']
)
response = requests.get('http://google.com')
logger.log(response)

You can add additional data into the meta field.

logger = frl.client.ClientRequestLogger(
    'logger-name',
    ['card_number', 'password']
)
def meta_logger(response):
   return {'foo': 'bar'}
logger.meta_population_methods.append(meta_logger)

About

Standardized logger for Flask and Requests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages