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 winston from "winston"
|
||||||
import { panicHandler } from "./panic-handler"
|
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 LOG_FILE = process.env.LOG_FILE || ""
|
||||||
const NODE_ENV = process.env.NODE_ENV || "development"
|
const NODE_ENV = process.env.NODE_ENV || "development"
|
||||||
const IS_DEV = NODE_ENV.startsWith("dev")
|
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
|
* The middleware to use for logging. We write the log messages
|
||||||
* using winston, but rely on morgan to hook into HTTP requests
|
* using winston, but rely on morgan to hook into HTTP requests
|
||||||
*/
|
*/
|
||||||
const loggingMiddleware = morgan(IS_DEV ? "dev" : "tiny", {
|
const loggingMiddleware = morgan(
|
||||||
skip: shouldSkipHttpLog,
|
IS_DEV
|
||||||
stream: {
|
? ":method :url ← :referrer (:status) - :response-time ms"
|
||||||
write: (message: string) => logger.http(message),
|
: "combined",
|
||||||
},
|
{
|
||||||
})
|
skip: shouldSkipHttpLog,
|
||||||
|
stream: {
|
||||||
|
write: (message: string) => logger.http(message.trim()),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
app.use(loggingMiddleware)
|
app.use(loggingMiddleware)
|
||||||
app.use(cookieParser())
|
app.use(cookieParser())
|
||||||
|
|||||||
Reference in New Issue
Block a user