@sumor/logger
Advanced tools
Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "@sumor/logger", | ||
"description": "This is a lightweight logger for Node.JS. It can output logs in different levels, and you can customize the scope, id, and timezone.", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "sumor-cloud/logger", |
@@ -170,1 +170,27 @@ # logger | ||
``` | ||
### Global Language Setting | ||
```js | ||
process.env.LANGUAGE = 'zh-CN' | ||
import Logger from '@sumor/logger' | ||
const code = { | ||
info: { | ||
USER_LOGIN: 'The user logs in and the user ID is {id}' | ||
} | ||
} | ||
const i18n = { | ||
zh: { | ||
USER_LOGIN: '用户登录,用户ID为{id}' | ||
} | ||
} | ||
const logger = new Logger({ | ||
code, | ||
i18n | ||
}) | ||
logger.code('USER_LOGIN', { id: 'USER001' }) | ||
// You will see the following output: | ||
// 2020-01-01 00:00:00.000 INFO MAIN - 用户登录,用户ID为USER001 | ||
``` |
@@ -7,3 +7,3 @@ import getLevelMapping from './getLevelMapping.js' | ||
const levelMapping = getLevelMapping(config.code) | ||
const i18n = getI18n(config.language, getI18nConfig(config)) | ||
const i18nConfig = getI18nConfig(config) | ||
@@ -13,2 +13,3 @@ return (code, parameters) => { | ||
if (level) { | ||
const i18n = getI18n(config.language || process.env.LANGUAGE || 'en-US', i18nConfig) | ||
const message = i18n(code, parameters) | ||
@@ -15,0 +16,0 @@ return { |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
13326
191
196
4