@@ -2,9 +2,10 @@ import fs, {promises, constants} from "fs";
22import dayjs from 'dayjs' ;
33import utc from 'dayjs/plugin/utc.js' ;
44import winston from "winston" ;
5+ import jsonStringify from 'safe-stable-stringify' ;
56
67const { format } = winston ;
7- const { combine, printf, timestamp, padLevels, label, splat } = format ;
8+ const { combine, printf, timestamp, padLevels, label, splat, simple } = format ;
89
910dayjs . extend ( utc ) ;
1011
@@ -74,14 +75,16 @@ export const buildTrackString = (playObj) => {
7475export const sortByPlayDate = ( a , b ) => a . data . playDate . isAfter ( b . data . playDate ) ? 1 : - 1 ;
7576
7677const s = splat ( ) ;
77- // const SPLAT = Symbol.for('splat')
78+ const SPLAT = Symbol . for ( 'splat' )
7879
7980let longestLabel = 3 ;
80- export const defaultFormat = printf ( ( { level, message, label = 'App' , timestamp, /*[SPLAT]: splatInfo = {}, ...rest*/ } ) => {
81+ export const defaultFormat = printf ( ( { level, message, label = 'App' , timestamp, [ SPLAT ] : splatObj } ) => {
82+ let stringifyValue = splatObj !== undefined ? jsonStringify ( splatObj ) : '' ;
8183 if ( label . length > longestLabel ) {
8284 longestLabel = label . length ;
8385 }
84- return `${ timestamp } ${ level . padEnd ( 7 ) } : [${ label . padEnd ( longestLabel ) } ] ${ message } ` ;
86+
87+ return `${ timestamp } ${ level . padEnd ( 7 ) } : [${ label . padEnd ( longestLabel ) } ] ${ message } ${ stringifyValue !== '' ? ` ${ stringifyValue } ` : '' } ` ;
8588} ) ;
8689
8790export const labelledFormat = ( labelName = 'App' ) => {
0 commit comments