koatty_logger
Advanced tools
Comparing version 1.1.2 to 1.2.2
@@ -25,3 +25,3 @@ /** | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-require-imports": "off", | ||
// "@typescript-eslint/no-require-imports": "off", | ||
"@typescript-eslint/no-var-requires": "off", | ||
@@ -32,2 +32,3 @@ "@typescript-eslint/member-ordering": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-empty-interface": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
@@ -34,0 +35,0 @@ "@typescript-eslint/ban-types": ["error", |
@@ -5,2 +5,2 @@ # Changelog | ||
### 1.1.2 (2021-06-21) | ||
### [1.2.2](https://github.com/thinkkoa/koatty_logger/compare/v1.1.2...v1.2.2) (2021-11-22) |
@@ -8,2 +8,3 @@ export declare type LogLevelType = "DEBUG" | "INFO" | "WARN" | "ERROR"; | ||
logFilePath?: string; | ||
sensFields?: Set<string>; | ||
} | ||
@@ -22,2 +23,3 @@ /** | ||
private logFilePath; | ||
private sensFields; | ||
/** | ||
@@ -70,2 +72,10 @@ * Creates an instance of Logger. | ||
/** | ||
* getSensFields | ||
*/ | ||
getSensFields(): Set<string>; | ||
/** | ||
* setSensFields | ||
*/ | ||
setSensFields(fields: string[]): void; | ||
/** | ||
* 格式化 | ||
@@ -72,0 +82,0 @@ * |
@@ -9,12 +9,13 @@ "use strict"; | ||
* @LastEditors: Please set LastEditors | ||
* @LastEditTime: 2021-06-22 10:26:38 | ||
* @LastEditTime: 2021-11-22 18:40:09 | ||
* @License: BSD (3-Clause) | ||
* @Copyright (c) - <richenlin(at)gmail.com> | ||
*/ | ||
const fs_1 = tslib_1.__importDefault(require("fs")); | ||
const util_1 = tslib_1.__importDefault(require("util")); | ||
const helper = tslib_1.__importStar(require("koatty_lib")); | ||
const fsOpen = util_1.default.promisify(fs_1.default.open); | ||
const fsAppend = util_1.default.promisify(fs_1.default.appendFile); | ||
const fsClose = util_1.default.promisify(fs_1.default.close); | ||
const fs_1 = (0, tslib_1.__importDefault)(require("fs")); | ||
const util_1 = (0, tslib_1.__importStar)(require("util")); | ||
const helper = (0, tslib_1.__importStar)(require("koatty_lib")); | ||
const shield_1 = require("./shield"); | ||
const fsOpen = (0, util_1.promisify)(fs_1.default.open); | ||
const fsAppend = (0, util_1.promisify)(fs_1.default.appendFile); | ||
const fsClose = (0, util_1.promisify)(fs_1.default.close); | ||
const styles = { | ||
@@ -62,3 +63,3 @@ 'bold': ['\x1B[1m', '\x1B[22m'], | ||
constructor(opt) { | ||
var _a, _b, _c, _d, _e; | ||
var _a, _b, _c, _d, _e, _f; | ||
// 控制台日志级别 | ||
@@ -74,2 +75,4 @@ this.logLevel = "INFO"; | ||
this.logFileLevel = "WARN"; | ||
// 脱敏字段 | ||
this.sensFields = new Set(); | ||
if (process.env.LOGS_LEVEL && LogLevelObj[process.env.LOGS_LEVEL]) { | ||
@@ -96,2 +99,3 @@ this.logLevel = process.env.LOGS_LEVEL; | ||
this.logFilePath = (_e = opt.logFilePath) !== null && _e !== void 0 ? _e : this.logFilePath; | ||
this.sensFields = (_f = opt.sensFields) !== null && _f !== void 0 ? _f : this.sensFields; | ||
} | ||
@@ -160,2 +164,14 @@ } | ||
/** | ||
* getSensFields | ||
*/ | ||
getSensFields() { | ||
return this.sensFields; | ||
} | ||
/** | ||
* setSensFields | ||
*/ | ||
setSensFields(fields) { | ||
this.sensFields = new Set([...this.sensFields, ...fields]); | ||
} | ||
/** | ||
* 格式化 | ||
@@ -172,24 +188,3 @@ * | ||
try { | ||
// tslint:disable-next-line: one-variable-per-declaration | ||
let params = []; | ||
args.forEach((item) => { | ||
if (helper.isError(item)) { | ||
if (item.stack) { | ||
params.push(item.stack); | ||
} | ||
else { | ||
params.push(item); | ||
} | ||
} | ||
else if (helper.isArray(item)) { | ||
params = [...params, ...item]; | ||
} | ||
else if (helper.isObject(item)) { | ||
params.push(JSON.stringify(item)); | ||
} | ||
else { | ||
params.push(item); | ||
} | ||
}); | ||
params = [`[${helper.dateTime('', '')}]`, `[${name !== '' ? name.toUpperCase() : level}]`, ...params]; | ||
const params = [`[${helper.dateTime('', '')}]`, `[${name !== '' ? name.toUpperCase() : level}]`, JSON.stringify((0, shield_1.ShieldLog)(args, this.sensFields))]; | ||
if (level === "DEBUG") { | ||
@@ -196,0 +191,0 @@ Error.captureStackTrace(this.emptyObj); |
@@ -9,2 +9,3 @@ /** | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', // 测试用例运行环境 | ||
@@ -17,3 +18,21 @@ testMatch: ['<rootDir>/test/**/*.(spec|test).[jt]s'], // 匹配测试用例的路径规则 | ||
collectCoverage: true, // 是否收集测试时的覆盖率信息 | ||
coverageReporters: ['html', 'lcov', 'json', 'text', 'clover', 'text-summary'], // 收集测试时的覆盖率信息 | ||
coverageReporters: [ | ||
'html', | ||
'lcov', | ||
'json', | ||
'text', | ||
'clover', | ||
'text-summary', | ||
], // 收集测试时的覆盖率信息 | ||
// 将 `ts-jest` 的配置注入到运行时的全局变量中 | ||
globals: { | ||
'ts-jest': { | ||
// 是否使用 babel 配置来转译 | ||
babelConfig: true, | ||
// 编译 Typescript 所依赖的配置 | ||
tsconfig: '<rootDir>/tsconfig.json', | ||
// 是否启用报告诊断,这里是不启用 | ||
diagnostics: false, | ||
}, | ||
} | ||
}; |
{ | ||
"name": "koatty_logger", | ||
"version": "1.1.2", | ||
"version": "1.2.2", | ||
"description": "Logger for koatty.", | ||
@@ -9,6 +9,7 @@ "scripts": { | ||
"prepublishOnly": "npm test && npm run build", | ||
"release": "standard-version", | ||
"test": "npm run eslint && npm run build && jest --passWithNoTests", | ||
"release": "npm run prepublishOnly && standard-version", | ||
"pub": "git push --follow-tags origin && npm publish", | ||
"test": "npm run eslint && jest --passWithNoTests", | ||
"test:cov": "jest --collectCoverage --detectOpenHandles", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" | ||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s" | ||
}, | ||
@@ -38,3 +39,3 @@ "main": "./dist/index.js", | ||
}, | ||
"license": "MIT", | ||
"license": "BSD-3-Clause", | ||
"bugs": { | ||
@@ -51,17 +52,20 @@ "url": "https://github.com/thinkkoa/koatty_logger/issues" | ||
"devDependencies": { | ||
"@babel/core": "^7.x.x", | ||
"@babel/plugin-proposal-decorators": "^7.x.x", | ||
"@babel/preset-env": "^7.x.x", | ||
"@babel/preset-typescript": "^7.x.x", | ||
"@commitlint/cli": "^12.x.x", | ||
"@commitlint/config-conventional": "^12.x.x", | ||
"@types/cls-hooked": "^4.x.x", | ||
"@types/node": "^12.x.x", | ||
"@typescript-eslint/eslint-plugin": "^4.x.x", | ||
"@typescript-eslint/parser": "^4.x.x", | ||
"@commitlint/config-conventional": "^15.x.x", | ||
"@types/jest": "^27.x.x", | ||
"@types/koa": "^2.x.x", | ||
"@types/node": "^16.x.x", | ||
"@typescript-eslint/eslint-plugin": "^5.x.x", | ||
"@typescript-eslint/parser": "^5.x.x", | ||
"conventional-changelog-cli": "^2.x.x", | ||
"del-cli": "^3.x.x", | ||
"eslint": "^7.x.x", | ||
"eslint-plugin-jest": "^24.x.x", | ||
"husky": "^6.x.x", | ||
"del-cli": "^4.x.x", | ||
"eslint": "^8.x.x", | ||
"eslint-plugin-jest": "^25.x.x", | ||
"husky": "^7.x.x", | ||
"jest": "^27.x.x", | ||
"jest-html-reporters": "^2.x.x", | ||
"koatty_cacheable": "^1.x.x", | ||
"koatty_schedule": "^1.x.x", | ||
"standard-version": "^9.x.x", | ||
@@ -68,0 +72,0 @@ "ts-jest": "^27.x.x", |
{ | ||
"compilerOptions": { | ||
/* Basic Options */ | ||
"target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */, | ||
"target": "ES2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */, | ||
"module": "commonjs" /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, | ||
@@ -45,3 +45,4 @@ "lib": [ | ||
"types": [ | ||
"node" | ||
"node", | ||
"jest" | ||
] /* Type declaration files to be included in compilation. */, | ||
@@ -61,8 +62,8 @@ "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */, | ||
"exclude": [ | ||
"node_modules" | ||
"node_modules", | ||
"dist" | ||
], | ||
"include": [ | ||
"src", | ||
"src/**/*.json" | ||
"src/**/*" | ||
] | ||
} |
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
1807116
17
0
839
22