koatty_logger
Advanced tools
Comparing version 1.2.4 to 1.2.6
@@ -5,2 +5,6 @@ # Changelog | ||
### [1.2.4](https://github.com/thinkkoa/koatty_logger/compare/v1.1.2...v1.2.4) (2021-11-22) | ||
### [1.2.6](https://github.com/thinkkoa/koatty_logger/compare/v1.1.2...v1.2.6) (2021-11-23) | ||
# Changelog | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. |
@@ -83,4 +83,4 @@ export declare type LogLevelType = "DEBUG" | "INFO" | "WARN" | "ERROR"; | ||
* @param {string} name | ||
* @param {any[]} args | ||
* @returns {any[]} | ||
* @param {any[]|string} args | ||
* @returns {string} | ||
* @memberof Logger | ||
@@ -96,3 +96,3 @@ */ | ||
* @param {string} color | ||
* @param {any[]} args | ||
* @param {any[]|string} args | ||
* @memberof Logger | ||
@@ -99,0 +99,0 @@ */ |
@@ -9,3 +9,3 @@ "use strict"; | ||
* @LastEditors: Please set LastEditors | ||
* @LastEditTime: 2021-11-22 18:40:09 | ||
* @LastEditTime: 2021-11-23 16:49:37 | ||
* @License: BSD (3-Clause) | ||
@@ -178,4 +178,4 @@ * @Copyright (c) - <richenlin(at)gmail.com> | ||
* @param {string} name | ||
* @param {any[]} args | ||
* @returns {any[]} | ||
* @param {any[]|string} args | ||
* @returns {string} | ||
* @memberof Logger | ||
@@ -185,3 +185,3 @@ */ | ||
try { | ||
const params = [`[${helper.dateTime('', '')}]`, `[${name !== '' ? name.toUpperCase() : level}]`, JSON.stringify((0, shield_1.ShieldLog)(args, this.sensFields))]; | ||
const params = [`[${helper.dateTime('', '')}]`, `[${name}]`, ...(0, shield_1.ShieldLog)(args, this.sensFields)]; | ||
if (level === "DEBUG") { | ||
@@ -192,7 +192,7 @@ Error.captureStackTrace(this.emptyObj); | ||
} | ||
return params; | ||
return util_1.default.format.apply(null, params); | ||
} | ||
catch (e) { | ||
// console.error(e.stack); | ||
return []; | ||
return ""; | ||
} | ||
@@ -207,3 +207,3 @@ } | ||
* @param {string} color | ||
* @param {any[]} args | ||
* @param {any[]|string} args | ||
* @memberof Logger | ||
@@ -213,2 +213,3 @@ */ | ||
try { | ||
name = name !== '' ? name.toUpperCase() : level; | ||
const logLevel = this.getLevel(); | ||
@@ -225,3 +226,3 @@ if (LogLevelObj[level] < LogLevelObj[logLevel]) { | ||
const style = styles[color] || styles.grey; | ||
console.log.apply(null, [style[0], ...args, style[1]]); | ||
console.log(`${style[0]}${args}${style[1]}`); | ||
} | ||
@@ -250,2 +251,3 @@ // record log files | ||
try { | ||
name = name !== '' ? name.toUpperCase() : level; | ||
const logFilePath = this.getLogFilePath(); | ||
@@ -259,7 +261,6 @@ if (!helper.isDir(logFilePath)) { | ||
} | ||
name = name !== "" ? name : level; | ||
const file = `${logFilePath}${helper.sep}${name ? `${name}_` : ''}${helper.dateTime('', 'YYYY-MM-DD')}.log`; | ||
const fd = await fsOpen(file, 'a'); | ||
// tslint:disable-next-line: no-null-keyword | ||
await fsAppend(fd, `${util_1.default.format.apply(null, params)}\n`, 'utf8'); | ||
await fsAppend(fd, `${params}\n`, 'utf8'); | ||
await fsClose(fd); | ||
@@ -266,0 +267,0 @@ // tslint:disable-next-line: no-null-keyword |
{ | ||
"name": "koatty_logger", | ||
"version": "1.2.4", | ||
"version": "1.2.6", | ||
"description": "Logger for koatty.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
1807350
840