-
-
Notifications
You must be signed in to change notification settings - Fork 69
[cli] Add a tail command to follow server logs #85
Description
Could be helpful to have a way to display HTTP requests info.
In the CLI program we could add a command line parameter to the server
command, say --tail
which would display the HTTP requests being handled by the server.
In the core
package, we currently do not have a log
middleware. We'd need one and use the logger
to ourput nice output, but only if we used the --tail
option.
This means that in the config
we would need to add a new option to indicate if we want to display the server log or not.
The log middleware would be added to all middleware chains only if that config flag is true.
What I mean by middleware chains can be found in server.go:117
:
stdAuth := []middleware.Middleware{
middleware.Cors(),
middleware.WithDB(backend.DB, backend.Cache, getStripePortalURL),
.// ...
}
Since they are this function receive the config, the log middleware could accept a flag to be verbose or not, ex:
stdAuth := []middleware.Middleware{
middleware.Log(config.TailRequests),
middleware.Cors(),
middleware.WithDB(backend.DB, backend.Cache, getStripePortalURL),
// ...
}
Assuming the config
flag would be called TailRequests
and the log middleware Log
.
If TailRequests
is false the middleware simply do nothing.