feature: use application logger to log HTTP requests (#9655)

This commit is contained in:
Harminder Virk
2024-10-18 15:08:55 +05:30
committed by GitHub
parent 82e32f9da4
commit aa6a28ac56
2 changed files with 76 additions and 10 deletions

View File

@@ -18,7 +18,9 @@ if (!IS_DEV) {
transports.push(
new winston.transports.Console({
format: winston.format.combine(
winston.format.cli(),
winston.format.cli({
levels: winston.config.npm.levels,
}),
winston.format.splat()
),
})
@@ -169,6 +171,7 @@ export class Reporter {
* @param {String | Error} messageOrError - can either be a string with a
* message to log the error under; or an error object.
* @param {Error?} error - an error object to log message with
* Level 0
*/
error(messageOrError: string | Error, error?: Error) {
let message = messageOrError as string
@@ -273,9 +276,22 @@ export class Reporter {
return null
}
/**
* Logs a message at the silly level.
* @param {string} message - the message to log
* Level 6
*/
silly(message: string) {
this.loggerInstance_.log({
level: "silly",
message,
})
}
/**
* Logs a message at the info level.
* @param {string} message - the message to log
* Level 5
*/
debug(message: string) {
this.loggerInstance_.log({
@@ -284,9 +300,34 @@ export class Reporter {
})
}
/**
* Logs a message at the vebose level.
* @param {string} message - the message to log
* Level 4
*/
verbose(message: string) {
this.loggerInstance_.log({
level: "vebose",
message,
})
}
/**
* Logs a message at the http level.
* @param {string} message - the message to log
* Level 3
*/
http(message: string) {
this.loggerInstance_.log({
level: "http",
message,
})
}
/**
* Logs a message at the info level.
* @param {string} message - the message to log
* Level 2
*/
info(message: string) {
this.loggerInstance_.log({
@@ -298,8 +339,9 @@ export class Reporter {
/**
* Logs a message at the warn level.
* @param {string} message - the message to log
* Level 1
*/
warn = (message: string) => {
warn(message: string) {
this.loggerInstance_.warn({
level: "warn",
message,