debug-logfmt 1.0.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE → LICENSE.md} +0 -0
- package/index.js +54 -6
- package/package.json +34 -34
- package/CHANGELOG.md +0 -36
package/{LICENSE → LICENSE.md}
RENAMED
|
File without changes
|
package/index.js
CHANGED
|
@@ -1,15 +1,63 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const timeSpan = require('@kikobeats/time-span')({
|
|
4
|
+
format: require('pretty-ms')
|
|
5
|
+
})
|
|
3
6
|
const { encode } = require('@jclem/logfmt2')
|
|
4
|
-
const
|
|
7
|
+
const origDebug = require('debug')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This methods override the default `formatArgs` to don't print diff information.
|
|
11
|
+
*/
|
|
12
|
+
if (process.env.DEBUG_COLORS === 'false') {
|
|
13
|
+
origDebug.formatArgs = function formatArgs (args) {
|
|
14
|
+
args[0] = this.namespace + ' ' + args[0]
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
origDebug.formatArgs = function formatArgs (args) {
|
|
18
|
+
const colorCode = `\u001B[3${
|
|
19
|
+
this.color < 8 ? this.color : `8;5;${this.color}`
|
|
20
|
+
}`
|
|
21
|
+
const prefix = ` ${colorCode};1m${this.namespace} \u001B[0m`
|
|
22
|
+
args[0] = prefix + args[0].replace(/\n/g, `\n${prefix}`)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const createDebug = require('debug-fabulous')(origDebug)
|
|
5
27
|
|
|
6
28
|
const LEVELS = ['info', 'warn', 'error']
|
|
7
29
|
|
|
8
|
-
const createLogger =
|
|
9
|
-
log
|
|
30
|
+
const createLogger =
|
|
31
|
+
log =>
|
|
32
|
+
(...args) =>
|
|
33
|
+
log(
|
|
34
|
+
args.map(arg => (typeof arg === 'string' ? arg : encode(arg))).join(' ')
|
|
35
|
+
)
|
|
10
36
|
|
|
11
37
|
module.exports = (env, { levels = LEVELS } = {}) => {
|
|
12
|
-
const
|
|
13
|
-
levels.forEach(
|
|
14
|
-
|
|
38
|
+
const debug = createLogger(createDebug(env))
|
|
39
|
+
levels.forEach(
|
|
40
|
+
level => (debug[level] = createLogger(createDebug(`${env}:${level}`)))
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
debug.duration = (...args) => {
|
|
44
|
+
const duration = timeSpan()
|
|
45
|
+
|
|
46
|
+
const create =
|
|
47
|
+
type =>
|
|
48
|
+
(...opts) => {
|
|
49
|
+
;(type ? debug[type] : debug)(...args, ...opts, {
|
|
50
|
+
duration: duration()
|
|
51
|
+
})
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const fn = create()
|
|
56
|
+
fn.error = create('error')
|
|
57
|
+
fn.info = create('info')
|
|
58
|
+
|
|
59
|
+
return fn
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return debug
|
|
15
63
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "debug-logfmt",
|
|
3
3
|
"description": "debug module using logfmt format",
|
|
4
|
-
"homepage": "https://
|
|
5
|
-
"version": "1.0
|
|
4
|
+
"homepage": "https://github.com/Kikobeats/debug-logfmt",
|
|
5
|
+
"version": "1.2.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "josefrancisco.verdu@gmail.com",
|
|
@@ -27,12 +27,15 @@
|
|
|
27
27
|
"winston"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@jclem/logfmt2": "~2.4.
|
|
31
|
-
"
|
|
30
|
+
"@jclem/logfmt2": "~2.4.3",
|
|
31
|
+
"@kikobeats/time-span": "~1.0.2",
|
|
32
|
+
"debug-fabulous": "~2.0.2",
|
|
33
|
+
"pretty-ms": "~7.0.1"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@commitlint/cli": "latest",
|
|
35
37
|
"@commitlint/config-conventional": "latest",
|
|
38
|
+
"@ksmithut/prettier-standard": "latest",
|
|
36
39
|
"ava": "latest",
|
|
37
40
|
"ci-publish": "latest",
|
|
38
41
|
"conventional-github-releaser": "latest",
|
|
@@ -40,11 +43,10 @@
|
|
|
40
43
|
"finepack": "latest",
|
|
41
44
|
"git-authors-cli": "latest",
|
|
42
45
|
"git-dirty": "latest",
|
|
43
|
-
"
|
|
44
|
-
"lint-staged": "latest",
|
|
46
|
+
"nano-staged": "latest",
|
|
45
47
|
"npm-check-updates": "latest",
|
|
46
48
|
"nyc": "latest",
|
|
47
|
-
"
|
|
49
|
+
"simple-git-hooks": "latest",
|
|
48
50
|
"standard": "latest",
|
|
49
51
|
"standard-markdown": "latest",
|
|
50
52
|
"standard-version": "latest"
|
|
@@ -55,6 +57,30 @@
|
|
|
55
57
|
"files": [
|
|
56
58
|
"index.js"
|
|
57
59
|
],
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"commitlint": {
|
|
62
|
+
"extends": [
|
|
63
|
+
"@commitlint/config-conventional"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"nano-staged": {
|
|
67
|
+
"*.js": [
|
|
68
|
+
"git add",
|
|
69
|
+
"prettier-standard"
|
|
70
|
+
],
|
|
71
|
+
"*.md": [
|
|
72
|
+
"git add",
|
|
73
|
+
"standard-markdown"
|
|
74
|
+
],
|
|
75
|
+
"package.json": [
|
|
76
|
+
"finepack",
|
|
77
|
+
"git add"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"simple-git-hooks": {
|
|
81
|
+
"commit-msg": "npx commitlint --edit",
|
|
82
|
+
"pre-commit": "npx nano-staged"
|
|
83
|
+
},
|
|
58
84
|
"scripts": {
|
|
59
85
|
"clean": "rm -rf node_modules",
|
|
60
86
|
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
|
@@ -69,31 +95,5 @@
|
|
|
69
95
|
"test": "exit 0",
|
|
70
96
|
"update": "ncu -a",
|
|
71
97
|
"update:check": "ncu -- --error-level 2"
|
|
72
|
-
},
|
|
73
|
-
"license": "MIT",
|
|
74
|
-
"commitlint": {
|
|
75
|
-
"extends": [
|
|
76
|
-
"@commitlint/config-conventional"
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
"husky": {
|
|
80
|
-
"hooks": {
|
|
81
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
82
|
-
"pre-commit": "lint-staged"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"lint-staged": {
|
|
86
|
-
"package.json": [
|
|
87
|
-
"finepack",
|
|
88
|
-
"git add"
|
|
89
|
-
],
|
|
90
|
-
"*.js": [
|
|
91
|
-
"prettier-standard",
|
|
92
|
-
"git add"
|
|
93
|
-
],
|
|
94
|
-
"*.md": [
|
|
95
|
-
"standard-markdown",
|
|
96
|
-
"git add"
|
|
97
|
-
]
|
|
98
98
|
}
|
|
99
|
-
}
|
|
99
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
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.
|
|
4
|
-
|
|
5
|
-
### [1.0.4](https://github.com/Kikobeats/debug-logfmt/compare/v1.0.3...v1.0.4) (2019-10-07)
|
|
6
|
-
|
|
7
|
-
### [1.0.3](https://github.com/Kikobeats/debug-logfmt/compare/v1.0.2...v1.0.3) (2019-08-23)
|
|
8
|
-
|
|
9
|
-
### [1.0.2](https://github.com/Kikobeats/debug-logfmt/compare/v1.0.1...v1.0.2) (2019-06-03)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
### Bug Fixes
|
|
13
|
-
|
|
14
|
-
* **package:** update logfmt to version 1.3.2 ([90640f6](https://github.com/Kikobeats/debug-logfmt/commit/90640f6))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### [1.0.1](https://github.com/Kikobeats/debug-logfmt/compare/v1.0.0...v1.0.1) (2019-05-21)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [1.0.0](https://github.com/Kikobeats/debug-logfmt/compare/v0.0.1...v1.0.0) (2019-05-21)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### 0.0.1 (2019-05-21)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### Bug Fixes
|
|
30
|
-
|
|
31
|
-
* linter ([9870aa2](https://github.com/Kikobeats/debug-logfmt/commit/9870aa2))
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Build System
|
|
35
|
-
|
|
36
|
-
* **no-release:** first commit ([fdea7ad](https://github.com/Kikobeats/debug-logfmt/commit/fdea7ad))
|