@percy/logger 1.9.1 → 1.10.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/dist/logger.js +9 -4
- package/package.json +2 -2
package/dist/logger.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { colors } from './utils.js';
|
|
2
|
+
const LINE_PAD_REGEXP = /^(\n*)(.*?)(\n*)$/s;
|
|
2
3
|
const URL_REGEXP = /https?:\/\/[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:;%_+.~#?&//=[\]]*)/i;
|
|
3
4
|
const LOG_LEVELS = {
|
|
4
5
|
debug: 0,
|
|
@@ -94,8 +95,10 @@ export class PercyLogger {
|
|
|
94
95
|
format(debug, level, message, elapsed) {
|
|
95
96
|
let color = (n, m) => this.isTTY ? colors[n](m) : m;
|
|
96
97
|
|
|
98
|
+
let begin,
|
|
99
|
+
end,
|
|
100
|
+
suffix = '';
|
|
97
101
|
let label = 'percy';
|
|
98
|
-
let suffix = '';
|
|
99
102
|
|
|
100
103
|
if (arguments.length === 1) {
|
|
101
104
|
// format(message)
|
|
@@ -103,10 +106,12 @@ export class PercyLogger {
|
|
|
103
106
|
} else if (arguments.length === 2) {
|
|
104
107
|
// format(debug, message)
|
|
105
108
|
[level, message] = [null, level];
|
|
106
|
-
}
|
|
109
|
+
} // do not format leading or trailing newlines
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
[, begin, message, end] = message.match(LINE_PAD_REGEXP); // include debug information
|
|
107
113
|
|
|
108
114
|
if (this.level === 'debug') {
|
|
109
|
-
// include debug info in the label
|
|
110
115
|
if (debug) label += `:${debug}`; // include elapsed time since last log
|
|
111
116
|
|
|
112
117
|
if (elapsed != null) {
|
|
@@ -128,7 +133,7 @@ export class PercyLogger {
|
|
|
128
133
|
message = message.replace(URL_REGEXP, color('blue', '$&'));
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
return
|
|
136
|
+
return `${begin}[${label}] ${message}${suffix}${end}`;
|
|
132
137
|
} // True if stdout is a TTY interface
|
|
133
138
|
|
|
134
139
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"test": "node ../../scripts/test",
|
|
32
32
|
"test:coverage": "yarn test --coverage"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "a6934eda4fc3b84845ae606d7f5a901f25e0a56f"
|
|
35
35
|
}
|