Skip to content

Commit 8758265

Browse files
fix(main): Support color formatting for individual console formats (#465)
* fix(main): Support color formatting for individual console formats * fix: Format can be a function * chore: Describe in the changelog --------- Co-authored-by: Alexey Prokhorov <[email protected]>
1 parent fcb6c8e commit 8758265

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 5.4.0
4+
5+
- [#465](https://github.com/megahertz/electron-log/issues/465) Allow using `%c`
6+
template for the `transports.console.format`. This change may break formatting
7+
if you already use `%c` in your format string. In this case, you can run
8+
`log.transports.console.transforms.shift()` before initializing the logger.
9+
310
## 5.2.4
411

512
- Add Buffering feature.

src/node/transports/console.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ function consoleTransportFactory(logger) {
6161
}
6262

6363
function addTemplateColors({ data, message, transport }) {
64-
if (transport.format !== DEFAULT_FORMAT) {
64+
if (
65+
typeof transport.format !== 'string'
66+
|| !transport.format.includes('%c')
67+
) {
6568
return data;
6669
}
6770

0 commit comments

Comments
 (0)