diff --git a/src/common/string-builder.ts b/src/common/string-builder.ts index d9ebac3..e2dad4c 100644 --- a/src/common/string-builder.ts +++ b/src/common/string-builder.ts @@ -1,5 +1,6 @@ import dateformat from 'dateformat'; import { GlobalLogConfig } from './types'; +import chalk from 'chalk'; class StringBuilder { private config: GlobalLogConfig; @@ -12,7 +13,7 @@ class StringBuilder { makePrefix(logType: string) { const prefix = this.config.prefixText ? `[${this.config.prefixText}][${logType}]` : `[Axios][${logType}]`; - this.printQueue.push(prefix); + this.printQueue.push(chalk.green(prefix)); return this; } @@ -28,7 +29,7 @@ class StringBuilder { } makeMethod(method?: string) { - if(method) this.printQueue.push(method.toUpperCase()); + if(method) this.printQueue.push(chalk.yellow(method.toUpperCase())); return this; } diff --git a/src/logger/request.ts b/src/logger/request.ts index f935c43..59ac2ba 100644 --- a/src/logger/request.ts +++ b/src/logger/request.ts @@ -13,8 +13,8 @@ function requestLogger(request: AxiosRequestConfig, config?: RequestLogConfig) { const log = stringBuilder .makePrefix('Request') .makeDateFormat() - .makeMethod(method) .makeUrl(url) + .makeMethod(method) .makeData(data) .build();