Skip to content

Commit aa2216f

Browse files
committed
feat(fancy/basic): support logObj.stack field
1 parent 2d4af39 commit aa2216f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Shortcut to `withDefaults({ scope })`.
138138

139139
- `level`
140140

141-
The level to display logs. Any logs at or above this level will be displayed.
141+
The level to display logs. Any logs at or above this level will be displayed.
142142
List of available levels [here](./src/types.js)
143143

144144
## logObject
@@ -158,6 +158,7 @@ Extended fields:
158158
- `clear`
159159
- `badge`
160160
- `additional`
161+
- `stack`
161162
- `additionalStyle` (By default: `grey`)
162163
- `icon` (Default depends on log type)
163164

src/reporters/basic.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ export default class BasicReporter {
2121
if (logObj.additional) {
2222
this.stream.write(logObj.additional + '\n')
2323
}
24+
25+
if (logObj.stack) {
26+
this.stream.write(logObj.stack + '\n')
27+
}
2428
}
2529
}

src/reporters/fancy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,11 @@ export default class FancyReporter {
5959
const lines = logObj.additional.split('\n').map(s => ' ' + s).join('\n')
6060
this.stream.write(chalk[logObj.additionalStyle || 'grey'](lines) + '\n')
6161
}
62+
63+
if (logObj.stack) {
64+
const stack = Array.isArray(logObj.stack) ? logObj.stack : logObj.stack.split('\n')
65+
const lines = stack.map(s => ' ' + s.trim()).join('\n')
66+
this.stream.write(chalk[logObj.additionalStyle || 'grey'](lines) + '\n')
67+
}
6268
}
6369
}

0 commit comments

Comments
 (0)