Comparing version 3.1.2 to 3.1.3
@@ -5,2 +5,7 @@ # Changelog | ||
## [3.1.3][] - 2021-07-22 | ||
- Improve code style | ||
- Move types to package root | ||
## [3.1.2][] - 2021-05-24 | ||
@@ -43,3 +48,4 @@ | ||
[unreleased]: https://github.com/metarhia/metalog/compare/v3.1.2...HEAD | ||
[unreleased]: https://github.com/metarhia/metalog/compare/v3.1.3...HEAD | ||
[3.1.3]: https://github.com/metarhia/metalog/compare/v3.1.2...v3.1.3 | ||
[3.1.2]: https://github.com/metarhia/metalog/compare/v3.1.1...v3.1.2 | ||
@@ -46,0 +52,0 @@ [3.1.1]: https://github.com/metarhia/metalog/compare/v3.1.0...v3.1.1 |
@@ -19,6 +19,10 @@ 'use strict'; | ||
const LINE_SEPARATOR = ';'; | ||
const INDENT = 2; | ||
const DATE_LEN = 'YYYY-MM-DD'.length; | ||
const TIME_START = DATE_LEN + 1; | ||
const TIME_END = TIME_START + 'HH:MM:SS'.length; | ||
const LOG_TYPES = ['error', 'warn', 'info', 'debug', 'log']; | ||
const LOG_TYPES = ['log', 'info', 'warn', 'debug', 'error']; | ||
const typeColor = concolor({ | ||
const TYPE_COLOR = concolor({ | ||
log: 'b,black/white', | ||
@@ -31,3 +35,3 @@ info: 'b,white/blue', | ||
const textColor = concolor({ | ||
const TEXT_COLOR = concolor({ | ||
log: 'white', | ||
@@ -40,5 +44,12 @@ info: 'white', | ||
const logTypes = (types) => { | ||
types = types || LOG_TYPES; | ||
const flags = {}; | ||
const DEFAULT_FLAGS = { | ||
log: false, | ||
info: false, | ||
warn: false, | ||
debug: false, | ||
error: false, | ||
}; | ||
const logTypes = (types = LOG_TYPES) => { | ||
const flags = { ...DEFAULT_FLAGS }; | ||
for (const type of types) { | ||
@@ -60,3 +71,4 @@ flags[type] = true; | ||
const nameToDays = (fileName) => { | ||
const fileTime = new Date(fileName.substring(0, 10)).getTime(); | ||
const date = fileName.substring(0, DATE_LEN); | ||
const fileTime = new Date(date).getTime(); | ||
return Math.floor(fileTime / DAY_MILLISECONDS); | ||
@@ -121,3 +133,3 @@ }; | ||
if (args.length !== 0) this.log(...args); | ||
this._groupIndent = ' '.repeat(this._groupIndent.length + 2); | ||
this._groupIndent = ' '.repeat(this._groupIndent.length + INDENT); | ||
} | ||
@@ -131,3 +143,3 @@ | ||
if (this._groupIndent.length === 0) return; | ||
this._groupIndent = ' '.repeat(this._groupIndent.length - 2); | ||
this._groupIndent = ' '.repeat(this._groupIndent.length - INDENT); | ||
} | ||
@@ -324,5 +336,5 @@ | ||
if (this.toStdout[type]) { | ||
const normalColor = textColor[type]; | ||
const markColor = typeColor[type]; | ||
const time = normalColor(dateTime.substring(11, 19)); | ||
const normalColor = TEXT_COLOR[type]; | ||
const markColor = TYPE_COLOR[type]; | ||
const time = normalColor(dateTime.substring(TIME_START, TIME_END)); | ||
const id = normalColor(this.workerId); | ||
@@ -329,0 +341,0 @@ const mark = markColor(' ' + type.padEnd(TYPE_LENGTH)); |
{ | ||
"name": "metalog", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -39,10 +39,11 @@ "description": "Logger for Metarhia", | ||
"main": "metalog.js", | ||
"types": "types/metalog.d.ts", | ||
"types": "metalog.d.ts", | ||
"readmeFilename": "README.md", | ||
"files": [ | ||
"types/" | ||
"types/", | ||
"metalog.d.ts" | ||
], | ||
"scripts": { | ||
"test": "npm run lint && npm run types && metatests test/", | ||
"types": "tsc -p types/tsconfig.json", | ||
"types": "tsc -p tsconfig.json", | ||
"lint": "eslint . && prettier --check \"**/*.js\" \"**/*.json\" \"**/*.md\" \"**/.*rc\" \"**/*.ts\"", | ||
@@ -55,16 +56,16 @@ "fmt": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\" \"**/.*rc\" \"**/*.ts\"" | ||
"dependencies": { | ||
"concolor": "^1.0.1", | ||
"metautil": "^3.5.3" | ||
"concolor": "^1.0.2", | ||
"metautil": "^3.5.8" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^15.6.0", | ||
"eslint": "^7.27.0", | ||
"@types/node": "^16.3.3", | ||
"eslint": "^7.31.0", | ||
"eslint-config-metarhia": "^7.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.23.3", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"metatests": "^0.7.2", | ||
"prettier": "^2.3.0", | ||
"typescript": "^4.2.4" | ||
"prettier": "^2.3.2", | ||
"typescript": "^4.3.5" | ||
} | ||
} |
@@ -32,10 +32,6 @@ # Meta Logger for Metarhia | ||
## Contributors | ||
## License & Contributors | ||
- Timur Shemsedinov <timur.shemsedinov@gmail.com> | ||
- See github for full [contributors list](https://github.com/metarhia/metalog/graphs/contributors) | ||
## License | ||
Copyright (c) 2017-2021 Metarhia contributors. | ||
Metalog is [MIT licensed](./LICENSE). | ||
Copyright (c) 2017-2021 [Metarhia contributors](https://github.com/metarhia/metalog/graphs/contributors). | ||
Metalog is [MIT licensed](./LICENSE).\ | ||
Metalog is a part of [Metarhia](https://github.com/metarhia) technology stack. |
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
17457
6
37
Updatedconcolor@^1.0.2
Updatedmetautil@^3.5.8