@icreate/core
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -170,3 +170,3 @@ /* | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-28 13:56:55 | ||
* @LastEditTime: 2022-04-15 16:16:30 | ||
* @Descripttion: | ||
@@ -178,4 +178,12 @@ * @FilePath: \src\core\logger.ts | ||
this.level = LogLevels.DEBUG; | ||
this.color = { | ||
debug: '#6e6e6e', | ||
info: '#2a53cd', | ||
warn: '#f4bd00', | ||
error: '#ce9178', | ||
fatal: '#eb3941' | ||
}; | ||
} | ||
Logger.prototype.log = function (logObject, logLevel) { | ||
Logger.prototype.log = function (logObject, logLevel, color) { | ||
if (color === void 0) { color = null; } | ||
if (typeof window === 'undefined' || !window.console || !window.console.log) { | ||
@@ -187,3 +195,8 @@ return; | ||
} | ||
console.log(logObject); | ||
if (color) { | ||
console.log(logObject, "color: " + color + ";font-size: 14px;font-weight: bold;line-height: 19px;font-family: Consolas, \"Courier New\", monospace;"); | ||
} | ||
else { | ||
console.log(logObject); | ||
} | ||
}; | ||
@@ -194,5 +207,7 @@ /** | ||
*/ | ||
Logger.prototype.debug = function (logObject) { | ||
this.log('DEBUG: ', LogLevels.DEBUG); | ||
Logger.prototype.debug = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [DEBUG] (" + message + ")", LogLevels.DEBUG, this.color.debug); | ||
this.log(logObject, LogLevels.DEBUG); | ||
this.log('', LogLevels.DEBUG); | ||
}; | ||
@@ -203,5 +218,7 @@ /** | ||
*/ | ||
Logger.prototype.info = function (logObject) { | ||
this.log('INFO: ', LogLevels.INFO); | ||
Logger.prototype.info = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [INFO] (" + message + ")", LogLevels.INFO, this.color.info); | ||
this.log(logObject, LogLevels.INFO); | ||
this.log('', LogLevels.INFO); | ||
}; | ||
@@ -212,5 +229,7 @@ /** | ||
*/ | ||
Logger.prototype.warn = function (logObject) { | ||
this.log('WARN: ', LogLevels.WARN); | ||
Logger.prototype.warn = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [WARN] (" + message + ")", LogLevels.WARN, this.color.warn); | ||
this.log(logObject, LogLevels.WARN); | ||
this.log('', LogLevels.WARN); | ||
}; | ||
@@ -221,5 +240,7 @@ /** | ||
*/ | ||
Logger.prototype.error = function (logObject) { | ||
this.log('ERROR: ', LogLevels.ERROR); | ||
Logger.prototype.error = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [ERROR] (" + message + ")", LogLevels.ERROR, this.color.error); | ||
this.log(logObject, LogLevels.ERROR); | ||
this.log('', LogLevels.ERROR); | ||
}; | ||
@@ -230,5 +251,7 @@ /** | ||
*/ | ||
Logger.prototype.fatal = function (logObject) { | ||
this.log('FATAL: ', LogLevels.FATAL); | ||
Logger.prototype.fatal = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [FATAL] (" + message + ")", LogLevels.FATAL, this.color.fatal); | ||
this.log(logObject, LogLevels.FATAL); | ||
this.log('', LogLevels.FATAL); | ||
}; | ||
@@ -235,0 +258,0 @@ return Logger; |
@@ -175,3 +175,3 @@ (function (global, factory) { | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-28 13:56:55 | ||
* @LastEditTime: 2022-04-15 16:16:30 | ||
* @Descripttion: | ||
@@ -183,4 +183,12 @@ * @FilePath: \src\core\logger.ts | ||
this.level = exports.LogLevels.DEBUG; | ||
this.color = { | ||
debug: '#6e6e6e', | ||
info: '#2a53cd', | ||
warn: '#f4bd00', | ||
error: '#ce9178', | ||
fatal: '#eb3941' | ||
}; | ||
} | ||
Logger.prototype.log = function (logObject, logLevel) { | ||
Logger.prototype.log = function (logObject, logLevel, color) { | ||
if (color === void 0) { color = null; } | ||
if (typeof window === 'undefined' || !window.console || !window.console.log) { | ||
@@ -192,3 +200,8 @@ return; | ||
} | ||
console.log(logObject); | ||
if (color) { | ||
console.log(logObject, "color: " + color + ";font-size: 14px;font-weight: bold;line-height: 19px;font-family: Consolas, \"Courier New\", monospace;"); | ||
} | ||
else { | ||
console.log(logObject); | ||
} | ||
}; | ||
@@ -199,5 +212,7 @@ /** | ||
*/ | ||
Logger.prototype.debug = function (logObject) { | ||
this.log('DEBUG: ', exports.LogLevels.DEBUG); | ||
Logger.prototype.debug = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [DEBUG] (" + message + ")", exports.LogLevels.DEBUG, this.color.debug); | ||
this.log(logObject, exports.LogLevels.DEBUG); | ||
this.log('', exports.LogLevels.DEBUG); | ||
}; | ||
@@ -208,5 +223,7 @@ /** | ||
*/ | ||
Logger.prototype.info = function (logObject) { | ||
this.log('INFO: ', exports.LogLevels.INFO); | ||
Logger.prototype.info = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [INFO] (" + message + ")", exports.LogLevels.INFO, this.color.info); | ||
this.log(logObject, exports.LogLevels.INFO); | ||
this.log('', exports.LogLevels.INFO); | ||
}; | ||
@@ -217,5 +234,7 @@ /** | ||
*/ | ||
Logger.prototype.warn = function (logObject) { | ||
this.log('WARN: ', exports.LogLevels.WARN); | ||
Logger.prototype.warn = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [WARN] (" + message + ")", exports.LogLevels.WARN, this.color.warn); | ||
this.log(logObject, exports.LogLevels.WARN); | ||
this.log('', exports.LogLevels.WARN); | ||
}; | ||
@@ -226,5 +245,7 @@ /** | ||
*/ | ||
Logger.prototype.error = function (logObject) { | ||
this.log('ERROR: ', exports.LogLevels.ERROR); | ||
Logger.prototype.error = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [ERROR] (" + message + ")", exports.LogLevels.ERROR, this.color.error); | ||
this.log(logObject, exports.LogLevels.ERROR); | ||
this.log('', exports.LogLevels.ERROR); | ||
}; | ||
@@ -235,5 +256,7 @@ /** | ||
*/ | ||
Logger.prototype.fatal = function (logObject) { | ||
this.log('FATAL: ', exports.LogLevels.FATAL); | ||
Logger.prototype.fatal = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [FATAL] (" + message + ")", exports.LogLevels.FATAL, this.color.fatal); | ||
this.log(logObject, exports.LogLevels.FATAL); | ||
this.log('', exports.LogLevels.FATAL); | ||
}; | ||
@@ -240,0 +263,0 @@ return Logger; |
@@ -7,6 +7,14 @@ "use strict"; | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-28 13:56:55 | ||
* @LastEditTime: 2022-04-15 16:16:30 | ||
* @Descripttion: | ||
* @FilePath: \src\core\logger.ts | ||
*/ | ||
/* | ||
* @Author: 文贝 | ||
* @Date: 2022-02-09 00:24:01 | ||
* @LastEditors: 文贝 | ||
* @LastEditTime: 2022-03-11 10:03:58 | ||
* @Descripttion: | ||
* @FilePath: \src\core\logger.ts | ||
*/ | ||
var interfaces_1 = require("../interfaces/interfaces"); | ||
@@ -16,4 +24,12 @@ var Logger = /** @class */ (function () { | ||
this.level = interfaces_1.LogLevels.DEBUG; | ||
this.color = { | ||
debug: '#6e6e6e', | ||
info: '#2a53cd', | ||
warn: '#f4bd00', | ||
error: '#ce9178', | ||
fatal: '#eb3941' | ||
}; | ||
} | ||
Logger.prototype.log = function (logObject, logLevel) { | ||
Logger.prototype.log = function (logObject, logLevel, color) { | ||
if (color === void 0) { color = null; } | ||
if (typeof window === 'undefined' || !window.console || !window.console.log) { | ||
@@ -25,3 +41,8 @@ return; | ||
} | ||
console.log(logObject); | ||
if (color) { | ||
console.log(logObject, "color: " + color + ";font-size: 14px;font-weight: bold;line-height: 19px;font-family: Consolas, \"Courier New\", monospace;"); | ||
} | ||
else { | ||
console.log(logObject); | ||
} | ||
}; | ||
@@ -32,5 +53,7 @@ /** | ||
*/ | ||
Logger.prototype.debug = function (logObject) { | ||
this.log('DEBUG: ', interfaces_1.LogLevels.DEBUG); | ||
Logger.prototype.debug = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [DEBUG] (" + message + ")", interfaces_1.LogLevels.DEBUG, this.color.debug); | ||
this.log(logObject, interfaces_1.LogLevels.DEBUG); | ||
this.log('', interfaces_1.LogLevels.DEBUG); | ||
}; | ||
@@ -41,5 +64,7 @@ /** | ||
*/ | ||
Logger.prototype.info = function (logObject) { | ||
this.log('INFO: ', interfaces_1.LogLevels.INFO); | ||
Logger.prototype.info = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [INFO] (" + message + ")", interfaces_1.LogLevels.INFO, this.color.info); | ||
this.log(logObject, interfaces_1.LogLevels.INFO); | ||
this.log('', interfaces_1.LogLevels.INFO); | ||
}; | ||
@@ -50,5 +75,7 @@ /** | ||
*/ | ||
Logger.prototype.warn = function (logObject) { | ||
this.log('WARN: ', interfaces_1.LogLevels.WARN); | ||
Logger.prototype.warn = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [WARN] (" + message + ")", interfaces_1.LogLevels.WARN, this.color.warn); | ||
this.log(logObject, interfaces_1.LogLevels.WARN); | ||
this.log('', interfaces_1.LogLevels.WARN); | ||
}; | ||
@@ -59,5 +86,7 @@ /** | ||
*/ | ||
Logger.prototype.error = function (logObject) { | ||
this.log('ERROR: ', interfaces_1.LogLevels.ERROR); | ||
Logger.prototype.error = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [ERROR] (" + message + ")", interfaces_1.LogLevels.ERROR, this.color.error); | ||
this.log(logObject, interfaces_1.LogLevels.ERROR); | ||
this.log('', interfaces_1.LogLevels.ERROR); | ||
}; | ||
@@ -68,5 +97,7 @@ /** | ||
*/ | ||
Logger.prototype.fatal = function (logObject) { | ||
this.log('FATAL: ', interfaces_1.LogLevels.FATAL); | ||
Logger.prototype.fatal = function (logObject, message) { | ||
if (message === void 0) { message = ''; } | ||
this.log("%c" + new Date().toLocaleString() + " [FATAL] (" + message + ")", interfaces_1.LogLevels.FATAL, this.color.fatal); | ||
this.log(logObject, interfaces_1.LogLevels.FATAL); | ||
this.log('', interfaces_1.LogLevels.FATAL); | ||
}; | ||
@@ -73,0 +104,0 @@ return Logger; |
import { ILogger, LogLevels } from '../interfaces/interfaces'; | ||
export default class Logger implements ILogger { | ||
level: LogLevels; | ||
private color; | ||
private log; | ||
@@ -9,3 +10,3 @@ /** | ||
*/ | ||
debug(logObject: any): void; | ||
debug(logObject: any, message?: string): void; | ||
/** | ||
@@ -15,3 +16,3 @@ * @description: 输出信息日志 | ||
*/ | ||
info(logObject: any): void; | ||
info(logObject: any, message?: string): void; | ||
/** | ||
@@ -21,3 +22,3 @@ * @description: 输出警告日志 | ||
*/ | ||
warn(logObject: any): void; | ||
warn(logObject: any, message?: string): void; | ||
/** | ||
@@ -27,3 +28,3 @@ * @description: 输出错误日志 | ||
*/ | ||
error(logObject: any): void; | ||
error(logObject: any, message?: string): void; | ||
/** | ||
@@ -33,3 +34,3 @@ * @description: 输出致命错误日志 | ||
*/ | ||
fatal(logObject: any): void; | ||
fatal(logObject: any, message?: string): void; | ||
} |
{ | ||
"name": "@icreate/core", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Ics核心包封装", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
162856
1999