@simplism/core
Advanced tools
Comparing version 10.3.22 to 10.3.48
@@ -6,3 +6,3 @@ import { DateTime } from "../type/DateTime"; | ||
private static readonly _palletColors; | ||
private static readonly _groupColorMap; | ||
private static readonly _prefixColorMap; | ||
static history: ILoggerHistory[]; | ||
@@ -9,0 +9,0 @@ private static readonly _groupMap; |
{ | ||
"name": "@simplism/core", | ||
"version": "10.3.22", | ||
"version": "10.3.48", | ||
"description": "Simplism Core Package", | ||
@@ -5,0 +5,0 @@ "repository": "github:kslhunter/simplism", |
@@ -19,3 +19,3 @@ import {DateTime} from "../type/DateTime"; | ||
]; | ||
private static readonly _groupColorMap = new Map<string, string>(); | ||
private static readonly _prefixColorMap = new Map<string, string>(); | ||
@@ -94,3 +94,4 @@ public static history: ILoggerHistory[] = []; | ||
}); | ||
} else { | ||
} | ||
else { | ||
this._groupMap.set(groupName, { | ||
@@ -106,3 +107,4 @@ ...Logger._defaultConfig, | ||
this._groupMap.delete(groupName); | ||
} else { | ||
} | ||
else { | ||
this._groupMap.clear(); | ||
@@ -133,4 +135,6 @@ } | ||
private _write(severity: LoggerSeverityString, logs: any[]): void { | ||
if (!Logger._groupColorMap.has(this._groupName)) { | ||
Logger._groupColorMap.set(this._groupName, Logger._palletColors[Logger._groupColorMap.size % Logger._palletColors.length]); | ||
if (this._prefix && !Logger._prefixColorMap.has(this._prefix)) { | ||
Logger._prefixColorMap.set( | ||
this._prefix, | ||
Logger._palletColors[Array.from(Logger._prefixColorMap.keys()).length % Logger._palletColors.length]); | ||
} | ||
@@ -154,7 +158,4 @@ | ||
// 로그 변환 | ||
const convertedLogs = logs.map(item => { | ||
// 색상있으면 색상 빼기 | ||
if (typeof item === "string") { | ||
return item.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ""); | ||
} else if (item instanceof Error) { | ||
let convertedLogs = logs.map(item => { | ||
if (item instanceof Error) { | ||
return item.stack; | ||
@@ -177,12 +178,4 @@ } | ||
if (this.config.consoleLogSeverities.includes(severity)) { | ||
/*let text = `${log.now} - [${log.severity}] - from ${log.group}`; | ||
if (process.env.NODE_ENV !== "production") { | ||
text += log.at ? " - " + log.at : ""; | ||
} | ||
text += `\r\n${log.prefix ? log.prefix + " " : ""}${convertedLogs.join("\r\n")}\r\n`; | ||
const text = `${this.config.color.grey}[${log.now}] ${log.group}\t${this.config.color[severity]}${log.severity.padEnd(5, " ")}\t${log.prefix ? Logger._prefixColorMap.get(log.prefix) + log.prefix + " " : ""}${this.config.color.log}${convertedLogs.join("\r\n")}${this.config.color.log}`; | ||
console.log(text);*/ | ||
const text = `${Logger._groupColorMap.get(this._groupName)}${log.group}:\t${this.config.color[severity]}${log.severity.padEnd(5, " ")}\t${this.config.color.log} ${log.prefix ? log.prefix + " " : ""}${convertedLogs.join("\r\n")}`; | ||
// 콘솔 출력 | ||
@@ -196,2 +189,11 @@ if (this.config.consoleLogSeverities.includes(severity)) { | ||
if (this.config.fileLogSeverities.includes(severity)) { | ||
convertedLogs = logs.map(item => { | ||
// 색상있으면 색상 빼기 | ||
if (typeof item === "string") { | ||
return item.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ""); | ||
} | ||
return item; | ||
}); | ||
let text = `${log.now} - [${log.severity}] - from ${log.group}`; | ||
@@ -212,3 +214,4 @@ text += log.at ? " - " + log.at : ""; | ||
fs.appendFileSync(filePath, `${text}\r\n`, "utf8"); | ||
} else { | ||
} | ||
else { | ||
fs.writeFileSync(filePath, `${text}\r\n`, "utf8"); | ||
@@ -215,0 +218,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
233724
36
3333