@dotcom-tool-kit/logger
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -15,2 +15,6 @@ "use strict"; | ||
const endRegex = new RegExp(`(?:(?:${ansiRegexText})|\s|\n)+$`); | ||
// RIS escape code to effectively do a clear (^L) on the terminal. TypeScript's | ||
// watch mode does this and it's annoying to have the logs shunted around when | ||
// tracking multiple tasks. | ||
const ansiReset = /\x1Bc/g; | ||
// Trim whitespace whilst preserving ANSI escape codes | ||
@@ -34,2 +38,13 @@ function ansiTrim(message) { | ||
} | ||
// Remove ANSI escape codes that mess with the terminal state. This selectively | ||
// only deletes escape codes we've seen causing issues so that other | ||
// functionality (particularly colouring) passes through fine. | ||
function stripAnsiReset(message) { | ||
return message.replace(ansiReset, ''); | ||
} | ||
// Collection of functions to make the hooked logs more readable, especially | ||
// when multiple tasks are running in a Tool Kit hook | ||
function cleanupLogs(message) { | ||
return stripAnsiReset(ansiTrim(message)); | ||
} | ||
// This function hooks winston into console.log statements. Most useful for when | ||
@@ -55,3 +70,3 @@ // calling functions from external libraries that you expect will do their own | ||
} | ||
logger.log(level, ansiTrim(message), { process: processName, writeCallback }); | ||
logger.log(level, cleanupLogs(message), { process: processName, writeCallback }); | ||
return true; | ||
@@ -91,3 +106,3 @@ } | ||
// consume | ||
callback(null, { level, message }); | ||
callback(null, { level, message: cleanupLogs(message) }); | ||
} | ||
@@ -94,0 +109,0 @@ })) |
@@ -15,2 +15,3 @@ import colours from 'ansi-colors'; | ||
title: colours.StyleFunction; | ||
taskHeader: colours.StyleFunction; | ||
errorHighlight: colours.StyleFunction; | ||
@@ -17,0 +18,0 @@ error: (string: string) => string; |
@@ -21,2 +21,3 @@ "use strict"; | ||
title: ansi_colors_1.default.bold.underline, | ||
taskHeader: ansi_colors_1.default.bgWhite.black, | ||
errorHighlight: ansi_colors_1.default.red, | ||
@@ -23,0 +24,0 @@ error: (string) => `${exports.styles.errorHighlight.bold('‼︎')} ${exports.styles.title(string)}`, |
{ | ||
"name": "@dotcom-tool-kit/logger", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
18055
336