Skip to content

Commit

Permalink
Add print color
Browse files Browse the repository at this point in the history
  • Loading branch information
hg-pyun committed Jun 28, 2019
1 parent 206219c commit 06a455f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/common/string-builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dateformat from 'dateformat';
import { GlobalLogConfig } from './types';
import chalk from 'chalk';

class StringBuilder {
private config: GlobalLogConfig;
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/logger/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 06a455f

Please sign in to comment.