mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-22 09:12:05 -07:00
fix(request logging): Logging requests to winston
This commit is contained in:
+13
-1
@@ -57,7 +57,19 @@ app.set("view engine", "jade")
|
||||
// Mount the docs
|
||||
app.use("/docs", express.static(`${__dirname}/../docs`))
|
||||
|
||||
app.use(logger("dev"))
|
||||
// Log each request to the console with IP addresses.
|
||||
// app.use(logger("dev"))
|
||||
const morganFormat = `:remote-addr :remote-user :method :url :status :response-time ms - :res[content-length] :user-agent`
|
||||
app.use(logger(morganFormat))
|
||||
|
||||
// Log the same data to the winston logs.
|
||||
const logStream = {
|
||||
write: function(message, encoding) {
|
||||
wlogger.info(`request: ${message}`)
|
||||
}
|
||||
}
|
||||
app.use(logger(morganFormat, { stream: logStream }))
|
||||
|
||||
app.use(bodyParser.json())
|
||||
app.use(bodyParser.urlencoded({ extended: false }))
|
||||
app.use(cookieParser())
|
||||
|
||||
Reference in New Issue
Block a user