guzmanthegood / guzfolio

Cryptocurrency portfolio tracker GrapQL API
MIT License
6 stars 2 forks source link

Create Request/Response Logging #14

Open guzmanthegood opened 3 years ago

guzmanthegood commented 3 years ago

Create some type of application monitoring with basic information about the requests that the users do. The log response should be in JSON format to be able to integrate it into a monitoring platform in the future.

You can start by creating a middleware that captures the necessary data and use, for example, logrus to log in a local file with a pretty format.

Difficulties:

Error example:

{
  "timestamp": "2019-03-04T11:21:07-05:00",
  "appname": "guzfolio",
  "level": "error",
  "status": "401",
  "query": "profile",
  "user": "user@guzfolio.dev",
  "msg": "authorization header required",
  "time":"61.702"
}

Info example:

{
  "timestamp": "2019-03-04T11:21:07-05:00",
  "appname": "guzfolio",
  "level": "info",
  "status": "200",
  "query": "createPortfolio",
  "user": "user@guzfolio.dev",
  "msg": "-",
  "time":"61.702"
}