morgan
morgan copied to clipboard
Support for promise
I am writing a custom token with async callback method that looks up value in a database. Problem is http request is logged in as [object Promise] for the custom token and doesn't "await" for the value to be resolved. Is there a workaround for this?
Hi @thethakuri right now all format functions and token functions are expected to be sync. We can add async support, however.
Maybe you can do this:
morgan(
(tokens, req, res) => {
oneAsyncFunction(tokens, req, res)
return null
},
{ ... }
)
you can replace stream function.