Fix/production logging (#9658)
Keep the old format (ie combined) when logging in production. **Development**  **Production** 
This commit is contained in:
@@ -5,7 +5,7 @@ import { ulid } from "ulid"
|
||||
import winston from "winston"
|
||||
import { panicHandler } from "./panic-handler"
|
||||
|
||||
const LOG_LEVEL = process.env.LOG_LEVEL || "info"
|
||||
const LOG_LEVEL = process.env.LOG_LEVEL || "http"
|
||||
const LOG_FILE = process.env.LOG_FILE || ""
|
||||
const NODE_ENV = process.env.NODE_ENV || "development"
|
||||
const IS_DEV = NODE_ENV.startsWith("dev")
|
||||
|
||||
@@ -76,12 +76,17 @@ export async function expressLoader({ app }: { app: Express }): Promise<{
|
||||
* The middleware to use for logging. We write the log messages
|
||||
* using winston, but rely on morgan to hook into HTTP requests
|
||||
*/
|
||||
const loggingMiddleware = morgan(IS_DEV ? "dev" : "tiny", {
|
||||
skip: shouldSkipHttpLog,
|
||||
stream: {
|
||||
write: (message: string) => logger.http(message),
|
||||
},
|
||||
})
|
||||
const loggingMiddleware = morgan(
|
||||
IS_DEV
|
||||
? ":method :url ← :referrer (:status) - :response-time ms"
|
||||
: "combined",
|
||||
{
|
||||
skip: shouldSkipHttpLog,
|
||||
stream: {
|
||||
write: (message: string) => logger.http(message.trim()),
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
app.use(loggingMiddleware)
|
||||
app.use(cookieParser())
|
||||
|
||||
Reference in New Issue
Block a user