Skip to content

Commit c4781ff

Browse files
committed
refactor: logger & cliErrorHanlder
1 parent ec836fa commit c4781ff

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

packages/contentstack-utilities/src/logger/cliErrorHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class CLIErrorHandler {
7676
hidden,
7777
};
7878

79-
if (this.isDebug) {
79+
if (isApi || this.isDebug) {
8080
result.debug = this.extractDebugPayload(normalized, context);
8181
}
8282

packages/contentstack-utilities/src/logger/logger.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ export default class Logger {
6666
format: winston.format.combine(
6767
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
6868
winston.format.printf((info) => {
69+
const redactedInfo = this.redact(info); // Apply redaction here
6970
const colorizer = winston.format.colorize();
7071

7172
// Handle success type specifically
72-
const levelToColorize = info.level;
73+
const levelToColorize = redactedInfo.level;
7374
const levelText = levelToColorize.toUpperCase();
7475

75-
const timestamp = info.timestamp;
76-
const message = info.message;
76+
const timestamp = redactedInfo.timestamp;
77+
const message = redactedInfo.message;
7778

7879
let fullLine = `[${timestamp}] ${levelText}: ${message}`;
7980
return colorizer.colorize(levelToColorize, fullLine);
@@ -111,10 +112,6 @@ export default class Logger {
111112
}
112113
}
113114

114-
private isLogEntry(obj: any): obj is LogEntry {
115-
return typeof obj === 'object' && 'level' in obj && 'message' in obj;
116-
}
117-
118115
private shouldLog(level: LogType, target: 'console' | 'file'): boolean {
119116
const configLevel = target === 'console' ? this.config.consoleLogLevel : this.config.logLevel;
120117
const minLevel = configLevel ? logLevels[configLevel] : 2; // default: info

0 commit comments

Comments
 (0)