applay-utils 1.5.2 → 1.5.3
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/libs-custom/pino-caller.js +5 -4
- package/package.json +2 -1
- package/utils/logger.js +1 -1
|
@@ -7,14 +7,14 @@ const LINE_OFFSET = 7
|
|
|
7
7
|
const { symbols } = require('pino')
|
|
8
8
|
const { asJsonSym } = symbols
|
|
9
9
|
|
|
10
|
-
function traceCaller
|
|
10
|
+
function traceCaller(pinoInstance, options = { relativeTo: null, stackAdjustment: 0 }) {
|
|
11
11
|
const adjustment = options.stackAdjustment || 0
|
|
12
12
|
|
|
13
|
-
function get
|
|
13
|
+
function get(target, name) {
|
|
14
14
|
return name === asJsonSym ? asJson : target[name]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function asJson
|
|
17
|
+
function asJson(...args) {
|
|
18
18
|
args[0] = args[0] || Object.create(null)
|
|
19
19
|
args[0].caller = Error().stack.split('\n').slice(2).filter(s => !s.includes('node_modules/pino') && !s.includes('node_modules\\pino'))[STACKTRACE_OFFSET + adjustment].substr(LINE_OFFSET)
|
|
20
20
|
if (options && typeof options.relativeTo === 'string') {
|
|
@@ -25,7 +25,8 @@ function traceCaller (pinoInstance, options = {relativeTo: null, stackAdjustment
|
|
|
25
25
|
.replace(hasTrailingSlash ? options.relativeTo : options.relativeTo + '/', '')
|
|
26
26
|
.replace(hasTrailingSlash ? options.relativeTo : options.relativeTo + '\\', '');
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
const position = args[0].caller.replace(')', '').split(':').slice(1)
|
|
29
30
|
|
|
30
31
|
args[0].caller = `Linha:${position[0]} - Coluna:${position[1]}`
|
|
31
32
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applay-utils",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Utilitary tools for Applay applications",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm version patch",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"mongodb": "^4.12.1",
|
|
21
21
|
"pg": "^8.8.0",
|
|
22
22
|
"pino": "^8.15.0",
|
|
23
|
+
"pino-caller": "^3.4.0",
|
|
23
24
|
"ssh2-sftp-client": "^9.0.4"
|
|
24
25
|
}
|
|
25
26
|
}
|
package/utils/logger.js
CHANGED
|
@@ -2,7 +2,7 @@ var pino = require('pino');
|
|
|
2
2
|
|
|
3
3
|
var logger = (prefix, filelog, nivel) => {
|
|
4
4
|
var modLogger = !filelog ? pino() : pino(pino.destination(`./logs/${filelog}.log`));
|
|
5
|
-
var pinoCaller = require('../libs-custom/pino-caller')(modLogger, { stackAdjustment: nivel || 1 })
|
|
5
|
+
var pinoCaller = require('../libs-custom/pino-caller')(modLogger, { relativeTo: 'any', stackAdjustment: nivel || 1 })
|
|
6
6
|
var consoleFunc = {
|
|
7
7
|
log: (...args) => {
|
|
8
8
|
if (typeof args[0] != 'string') { args.unshift(''); }
|