@antora/logger
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -9,4 +9,5 @@ 'use strict' | ||
levels: { labels: levelLabels, values: levelValues }, | ||
symbols: { serializersSym: $serializers, streamSym: $stream }, | ||
symbols: { streamSym: $stream }, | ||
pino, | ||
stdSerializers: { err: defaultErrSerializer }, | ||
} = require('pino') | ||
@@ -16,5 +17,7 @@ const { default: pinoPretty, prettyFactory } = require('pino-pretty') | ||
const INF = Infinity | ||
const WRAP = '\n ' | ||
const closedLogger = { closed: true } | ||
const finalizers = [] | ||
const INF = Infinity | ||
const minLevel = levelLabels[Math.min.apply(null, Object.keys(levelLabels))] | ||
@@ -24,2 +27,6 @@ const noopLogger = pino({ base: null, enabled: false, timestamp: false }, {}) | ||
const standardStreams = { 1: 1, 2: 2, stderr: 2, stdout: 1 } | ||
const errSerializer = (err) => { | ||
if (!(err = defaultErrSerializer(err)).message) delete err.message | ||
return err | ||
} | ||
@@ -67,3 +74,3 @@ function close () { | ||
if (arg0 instanceof Error) { | ||
reshapeErrorForLog(arg0, args[1], prettyPrint && this[$serializers].err).forEach((v, i) => (args[i] = v)) | ||
reshapeErrorForLog(arg0, args[1], prettyPrint && errSerializer).forEach((v, i) => (args[i] = v)) | ||
} else if (arg0.constructor === Object && typeof arg0.file === 'object') { | ||
@@ -76,2 +83,3 @@ const { file, line, stack, ...obj } = arg0 | ||
}, | ||
serializers: { err: errSerializer }, | ||
} | ||
@@ -128,27 +136,23 @@ close() | ||
file: ({ path: path_, line }) => (line == null ? path_ : `${path_}:${line}`), | ||
stack: (stack, _, log) => { | ||
stack (stack, _, { source: prevSource = {} }) { | ||
if (!Array.isArray(stack)) return JSON.stringify(stack, null, 2) | ||
let prevSource = log.source | ||
return stack | ||
.map(({ file: { path: path_, line }, source }) => { | ||
const file = `${path_}:${line}` | ||
.map(({ file: { path: path_, line }, source = {} }) => { | ||
const file = line == null ? path_ : `${path_}:${line}` | ||
const sameSource = | ||
prevSource && | ||
source.url === prevSource.url && | ||
source.reftype === prevSource.reftype && | ||
source.refname === prevSource.refname && | ||
source.worktree === prevSource.worktree && | ||
source.startPath === prevSource.startPath | ||
prevSource = source | ||
if (sameSource) return `\n file: ${file}` | ||
const { url, worktree, refname, startPath } = source | ||
source = worktree | ||
? `${worktree} (refname: ${refname} <worktree>${startPath ? ', start path: ' + startPath : ''})` | ||
: `${url || '<unknown>'} (refname: ${refname}${startPath ? ', start path: ' + startPath : ''})` | ||
return `\n file: ${file}\n source: ${source}` | ||
return sameSource ? `${WRAP}file: ${file}` : `${WRAP}file: ${file}${WRAP}source: ${this.source(source)}` | ||
}) | ||
.join('') | ||
}, | ||
source: ({ url, worktree, refname, startPath }) => | ||
worktree | ||
? `${worktree} (refname: ${refname} <worktree>${startPath ? ', start path: ' + startPath : ''})` | ||
: `${url || '<unknown>'} (refname: ${refname}${startPath ? ', start path: ' + startPath : ''})`, | ||
source: ({ url, local, worktree, refname, reftype, remote, startPath }) => { | ||
const pathInfo = startPath ? ` | start path: ${startPath}` : '' | ||
const flag = worktree ? ' <worktree>' : remote ? ` <remotes/${remote}>` : '' | ||
return `${worktree || local || url || '<unknown>'} (${reftype}: ${refname}${flag}${pathInfo})` | ||
}, | ||
}, | ||
@@ -177,3 +181,3 @@ ignore: 'hint', | ||
function reshapeErrorForLog (err, msg, prettyPrint, serialize) { | ||
function reshapeErrorForLog (err, msg, prettyPrint) { | ||
const { name, message } = err | ||
@@ -187,3 +191,3 @@ let stack | ||
} else if ((stack = err.stack || name) && err instanceof SyntaxError && stack.includes('\nSyntaxError: ')) { | ||
stack = `SyntaxError: ${message}\n at ` + stack.split(/\n+SyntaxError: [^\n]+\n?/).join('\n') | ||
stack = `SyntaxError: ${message}${WRAP}at ` + stack.split(/\n+SyntaxError: [^\n]+\n?/).join('\n') | ||
} | ||
@@ -203,8 +207,9 @@ if (message && (message === msg || !prettyPrint) && stack.startsWith(`${name}: ${message}`)) { | ||
if (origin) { | ||
const { url, refname, startPath, worktree } = origin | ||
const { url, gitdir, worktree, tag, reftype = tag ? 'tag' : 'branch', refname, remote, startPath } = origin | ||
const local = 'worktree' in origin && (gitdir || url) | ||
const logObject = { | ||
file: { path: abspath || path.join(startPath, vpath), line }, | ||
source: worktree | ||
? { url, worktree, refname, startPath: startPath || undefined } | ||
: { url, refname, startPath: startPath || undefined }, | ||
source: local | ||
? { url, local, worktree, refname, reftype, remote, startPath: startPath || undefined } | ||
: { url, refname, reftype, startPath: startPath || undefined }, | ||
} | ||
@@ -211,0 +216,0 @@ if (stack) logObject.stack = stack.map(reshapeFileForLog) |
{ | ||
"name": "@antora/logger", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "The logger for Antora.", | ||
@@ -17,10 +17,14 @@ "license": "MPL-2.0", | ||
"main": "lib/index.js", | ||
"exports": { | ||
".": "./lib/index.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"dependencies": { | ||
"@antora/expand-path-helper": "~2.0", | ||
"pino": "~7.6", | ||
"pino-pretty": "~7.3", | ||
"sonic-boom": "~2.4" | ||
"pino": "~8.4", | ||
"pino-pretty": "~9.0", | ||
"sonic-boom": "~3.2" | ||
}, | ||
"engines": { | ||
"node": ">=12.21.0" | ||
"node": ">=16.0.0" | ||
}, | ||
@@ -27,0 +31,0 @@ "files": [ |
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
13094
270
+ Addedabort-controller@3.0.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-copy@2.1.7(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@8.1.0(transitive)
+ Addedhelp-me@4.2.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedon-exit-leak-free@2.1.2(transitive)
+ Addedpino@8.4.2(transitive)
+ Addedpino-pretty@9.0.1(transitive)
+ Addedpino-std-serializers@6.2.2(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-warning@2.3.2(transitive)
+ Addedreadable-stream@4.5.2(transitive)
+ Addedreal-require@0.2.0(transitive)
+ Addedsonic-boom@3.2.1(transitive)
+ Addedthread-stream@2.7.0(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargs@5.0.3(transitive)
- Removedcamelcase@5.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedleven@2.1.0(transitive)
- Removedmri@1.1.4(transitive)
- Removedon-exit-leak-free@0.2.0(transitive)
- Removedpino@7.6.5(transitive)
- Removedpino-pretty@7.3.0(transitive)
- Removedpino-std-serializers@4.0.0(transitive)
- Removedprocess-warning@1.0.0(transitive)
- Removedreal-require@0.1.0(transitive)
- Removedrfdc@1.4.1(transitive)
- Removedsonic-boom@2.4.2(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedthread-stream@0.13.2(transitive)
Updatedpino@~8.4
Updatedpino-pretty@~9.0
Updatedsonic-boom@~3.2