feat: Add optional http logging in production (#2183)
* feat: Add optional http logging in production closes #2174 * Update app.js
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// @flow
|
||||
import * as Sentry from "@sentry/node";
|
||||
import debug from "debug";
|
||||
import Koa from "koa";
|
||||
import compress from "koa-compress";
|
||||
import helmet, {
|
||||
@@ -21,6 +22,7 @@ import updates from "./utils/updates";
|
||||
const app = new Koa();
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
const isTest = process.env.NODE_ENV === "test";
|
||||
const log = debug("http");
|
||||
|
||||
// Construct scripts CSP based on services in use by this installation
|
||||
const defaultSrc = ["'self'"];
|
||||
@@ -105,11 +107,16 @@ if (isProduction) {
|
||||
})
|
||||
)
|
||||
);
|
||||
app.use(logger());
|
||||
|
||||
app.use(mount("/emails", emails));
|
||||
}
|
||||
|
||||
// redirect routing logger to optional "http" debug
|
||||
app.use(
|
||||
logger((str, args) => {
|
||||
log(str);
|
||||
})
|
||||
);
|
||||
|
||||
// catch errors in one place, automatically set status and response headers
|
||||
onerror(app);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user