[READ-ONLY] Mirror of https://github.com/FoxxMD/logging. A typed, opinionated, batteries-included, Pino-based logging solution for backend TS/JS projects foxxmd.github.io/logging
child-logger logging logging-library nodejs pinojs typescript-library
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: Use fixed patch for pino-pretty colorized message

FoxxMD (Mar 1, 2024, 4:09 PM EST) 1987215c aa8d87f6

+32 -6
+1
.gitignore
··· 10 10 .tshy 11 11 .tshy-build-tmp 12 12 dist 13 + tmp-*
+2 -2
package-lock.json
··· 1 1 { 2 2 "name": "@foxxmd/logging", 3 - "version": "0.1.0", 3 + "version": "0.0.2", 4 4 "lockfileVersion": 3, 5 5 "requires": true, 6 6 "packages": { 7 7 "": { 8 8 "name": "@foxxmd/logging", 9 - "version": "0.1.0", 9 + "version": "0.0.2", 10 10 "hasInstallScript": true, 11 11 "license": "MIT", 12 12 "dependencies": {
+29 -4
patches/pino-pretty+10.3.1.patch
··· 37 37 type PrettyStream = Transform & OnUnknown; 38 38 type ColorizerFactory = typeof colorizerFactory; 39 39 diff --git a/node_modules/pino-pretty/lib/colors.js b/node_modules/pino-pretty/lib/colors.js 40 - index 5bb3804..0896ae7 100644 40 + index 5bb3804..f135c33 100644 41 41 --- a/node_modules/pino-pretty/lib/colors.js 42 42 +++ b/node_modules/pino-pretty/lib/colors.js 43 43 @@ -1,7 +1,5 @@ ··· 91 91 return customColoredColorizer 92 92 } 93 93 94 - @@ -105,6 +96,7 @@ function customColoredColorizerFactory (customColors, useOnlyCustomProps) { 94 + @@ -88,6 +79,7 @@ function customColoredColorizerFactory (customColors, useOnlyCustomProps) { 95 + const customColoredColorizer = function (level, opts) { 96 + return colorizeLevelCustom(level, customColored, opts) 97 + } 98 + + customColoredColorizer.colors = availableColors 99 + customColoredColorizer.message = customColoredColorizer.message || customColored.message 100 + customColoredColorizer.greyMessage = customColoredColorizer.greyMessage || customColored.greyMessage 101 + 102 + @@ -105,6 +97,7 @@ function customColoredColorizerFactory (customColors, useOnlyCustomProps) { 95 103 * recognized. 96 104 * @property {function} message Accepts one string parameter that will be 97 105 * colorized to a predefined color. ··· 264 272 } 265 273 if (messageKey in log === false) return undefined 266 274 diff --git a/node_modules/pino-pretty/lib/utils/prettify-message.test.js b/node_modules/pino-pretty/lib/utils/prettify-message.test.js 267 - index 8faf4b1..291f971 100644 275 + index 8faf4b1..dadf8b1 100644 268 276 --- a/node_modules/pino-pretty/lib/utils/prettify-message.test.js 269 277 +++ b/node_modules/pino-pretty/lib/utils/prettify-message.test.js 270 - @@ -185,3 +185,37 @@ tap.test('`messageFormat` supports function definition', async t => { 278 + @@ -185,3 +185,54 @@ tap.test('`messageFormat` supports function definition', async t => { 271 279 }) 272 280 t.equal(str, '--> localhost/test') 273 281 }) 274 282 + 275 283 +tap.test('`messageFormat` supports function definition with colorizer object', async t => { 276 284 + const colorizer = getColorizer(true) 285 + + const str = prettifyMessage({ 286 + + log: { level: 30, request: { url: 'localhost/test' }, msg: 'incoming request' }, 287 + + context: { 288 + + ...context, 289 + + colorizer, 290 + + messageFormat: (log, messageKey, levelLabel, { colors }) => { 291 + + let msg = log[messageKey] 292 + + if (msg === 'incoming request') msg = `--> ${colors.red(log.request.url)}` 293 + + return msg 294 + + } 295 + + } 296 + + }) 297 + + t.equal(str, '\u001B[36m--> \u001B[31mlocalhost/test\u001B[36m\u001B[39m') 298 + +}) 299 + + 300 + +tap.test('`messageFormat` supports function definition with colorizer object when using custom colors', async t => { 301 + + const colorizer = getColorizer(true, [[30, 'brightGreen']], false) 277 302 + const str = prettifyMessage({ 278 303 + log: { level: 30, request: { url: 'localhost/test' }, msg: 'incoming request' }, 279 304 + context: {