@mhmdhammoud/meritt-utils 1.4.1 → 1.5.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/.github/workflows/npm-publish.yml +1 -1
- package/.github/workflows/push.yml +2 -2
- package/.husky/pre-commit +1 -1
- package/ReleaseNotes.md +4 -0
- package/dist/lib/logger.d.ts +2 -1
- package/dist/lib/logger.js +13 -4
- package/package.json +3 -3
- package/src/lib/logger.ts +17 -6
|
@@ -39,5 +39,5 @@ jobs:
|
|
|
39
39
|
password: ${{ secrets.EMAIL_PASSWORD }}
|
|
40
40
|
subject: ${{ github.event.head_commit.message }} ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
|
|
41
41
|
body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
|
|
42
|
-
to: mohammad.hammoud.lb@hotmail.com,steef12009@gmail.com
|
|
42
|
+
to: mohammad.hammoud.lb@hotmail.com,steef12009@gmail.com
|
|
43
43
|
from: Github Action
|
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
with:
|
|
12
12
|
node-version: 16
|
|
13
13
|
- run: npm ci
|
|
14
|
-
- run: npm run types
|
|
14
|
+
- run: npm run test:types
|
|
15
15
|
notify:
|
|
16
16
|
needs: [type-check]
|
|
17
17
|
runs-on: ubuntu-latest
|
|
@@ -25,5 +25,5 @@ jobs:
|
|
|
25
25
|
password: ${{ secrets.EMAIL_PASSWORD }}
|
|
26
26
|
subject: ${{ github.event.head_commit.message }} ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
|
|
27
27
|
body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
|
|
28
|
-
to: mohammad.hammoud.lb@hotmail.com,steef12009@gmail.com
|
|
28
|
+
to: mohammad.hammoud.lb@hotmail.com,steef12009@gmail.com
|
|
29
29
|
from: Github Action
|
package/.husky/pre-commit
CHANGED
package/ReleaseNotes.md
CHANGED
package/dist/lib/logger.d.ts
CHANGED
package/dist/lib/logger.js
CHANGED
|
@@ -52,7 +52,8 @@ function getLogger(elasticConfig) {
|
|
|
52
52
|
username: process.env.ELASTICSEARCH_USERNAME,
|
|
53
53
|
password: process.env.ELASTICSEARCH_PASSWORD,
|
|
54
54
|
},
|
|
55
|
-
flushInterval:
|
|
55
|
+
flushInterval: 1000,
|
|
56
|
+
'flush-bytes': 1000,
|
|
56
57
|
};
|
|
57
58
|
if (elasticConfig) {
|
|
58
59
|
Object.assign(esConfig, elasticConfig);
|
|
@@ -62,8 +63,8 @@ function getLogger(elasticConfig) {
|
|
|
62
63
|
}
|
|
63
64
|
else {
|
|
64
65
|
transports.push(pino_1.pino.destination({
|
|
65
|
-
minLength:
|
|
66
|
-
sync:
|
|
66
|
+
minLength: 128,
|
|
67
|
+
sync: false,
|
|
67
68
|
}));
|
|
68
69
|
}
|
|
69
70
|
pinoLogger = (0, pino_1.pino)({
|
|
@@ -96,10 +97,18 @@ class Logger {
|
|
|
96
97
|
this._logger = getLogger(elasticConfig);
|
|
97
98
|
}
|
|
98
99
|
log(logLevel, logEvent, ...args) {
|
|
100
|
+
let detail;
|
|
101
|
+
if (process.env.NODE_ENV === 'local' || process.env.NODE_ENV === 'test') {
|
|
102
|
+
detail = args;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
//@ts-ignore
|
|
106
|
+
detail = JSON.stringify(...args);
|
|
107
|
+
}
|
|
99
108
|
this._logger[logLevel]({
|
|
100
109
|
component: this._name,
|
|
101
110
|
...logEvent,
|
|
102
|
-
detail
|
|
111
|
+
detail,
|
|
103
112
|
});
|
|
104
113
|
}
|
|
105
114
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mhmdhammoud/meritt-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"dev
|
|
16
|
+
"start:dev": "ts-node-dev --respawn --transpile-only src/index.ts | pino-pretty",
|
|
17
17
|
"dev": "nodemon ./dist/index.js",
|
|
18
18
|
"watch": "tsc --watch",
|
|
19
19
|
"build": "tsc",
|
|
20
|
-
"types": "tsc --noemit",
|
|
20
|
+
"test:types": "tsc --noemit",
|
|
21
21
|
"prepare": "husky install",
|
|
22
22
|
"lint": "eslint src --fix",
|
|
23
23
|
"prepublish": "npm run build",
|
package/src/lib/logger.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Logger as PinoLogger, pino, stdTimeFunctions} from 'pino'
|
|
2
2
|
import * as dotenv from 'dotenv'
|
|
3
|
-
import pinoElastic from 'pino-elasticsearch'
|
|
4
|
-
import {
|
|
3
|
+
import pinoElastic, {Options as ElasticConfig} from 'pino-elasticsearch'
|
|
4
|
+
import {LOG_LEVEL, LogEvent} from '../types'
|
|
5
5
|
|
|
6
6
|
dotenv.config()
|
|
7
7
|
|
|
@@ -27,21 +27,25 @@ function getLogger(elasticConfig?: ElasticConfig): PinoLogger {
|
|
|
27
27
|
username: process.env.ELASTICSEARCH_USERNAME,
|
|
28
28
|
password: process.env.ELASTICSEARCH_PASSWORD,
|
|
29
29
|
},
|
|
30
|
-
flushInterval:
|
|
30
|
+
flushInterval: 1000,
|
|
31
|
+
'flush-bytes': 1000,
|
|
31
32
|
}
|
|
32
33
|
if (elasticConfig) {
|
|
33
34
|
Object.assign(esConfig, elasticConfig)
|
|
34
35
|
}
|
|
36
|
+
|
|
35
37
|
const esTransport = pinoElastic(esConfig)
|
|
38
|
+
|
|
36
39
|
transports.push(esTransport)
|
|
37
40
|
} else {
|
|
38
41
|
transports.push(
|
|
39
42
|
pino.destination({
|
|
40
|
-
minLength:
|
|
41
|
-
sync:
|
|
43
|
+
minLength: 128,
|
|
44
|
+
sync: false,
|
|
42
45
|
})
|
|
43
46
|
)
|
|
44
47
|
}
|
|
48
|
+
|
|
45
49
|
pinoLogger = pino(
|
|
46
50
|
{
|
|
47
51
|
level: process.env.LOG_LEVEL,
|
|
@@ -95,10 +99,17 @@ class Logger {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
private log(logLevel: LOG_LEVEL, logEvent: LogEvent, ...args: unknown[]) {
|
|
102
|
+
let detail
|
|
103
|
+
if (process.env.NODE_ENV === 'local' || process.env.NODE_ENV === 'test') {
|
|
104
|
+
detail = args
|
|
105
|
+
} else {
|
|
106
|
+
//@ts-ignore
|
|
107
|
+
detail = JSON.stringify(...args)
|
|
108
|
+
}
|
|
98
109
|
this._logger[logLevel]({
|
|
99
110
|
component: this._name,
|
|
100
111
|
...logEvent,
|
|
101
|
-
detail
|
|
112
|
+
detail,
|
|
102
113
|
})
|
|
103
114
|
}
|
|
104
115
|
|