@@ -23,10 +23,7 @@ function getLogLevel(level, action, payload, type) {
2323}
2424
2525function defaultTitleFormatter ( options ) {
26- const {
27- timestamp,
28- duration,
29- } = options ;
26+ const { timestamp, duration } = options ;
3027
3128 return ( action , time , took ) => {
3229 const parts = [ 'action' ] ;
@@ -64,7 +61,9 @@ function printBuffer(buffer, options) {
6461
6562 // Message
6663 const formattedAction = actionTransformer ( action ) ;
67- const isCollapsed = ( typeof collapsed === 'function' ) ? collapsed ( ( ) => nextState , action , logEntry ) : collapsed ;
64+ const isCollapsed = typeof collapsed === 'function'
65+ ? collapsed ( ( ) => nextState , action , logEntry )
66+ : collapsed ;
6867
6968 const formattedTime = formatTime ( startedTime ) ;
7069 const titleCSS = colors . title ? `color: ${ colors . title ( formattedAction ) } ;` : '' ;
@@ -77,8 +76,7 @@ function printBuffer(buffer, options) {
7776 // Render
7877 try {
7978 if ( isCollapsed ) {
80- if ( colors . title && isUsingDefaultFormatter ) logger . groupCollapsed ( `%c ${ title } ` , ...headerCSS ) ;
81- else logger . groupCollapsed ( title ) ;
79+ if ( colors . title && isUsingDefaultFormatter ) { logger . groupCollapsed ( `%c ${ title } ` , ...headerCSS ) ; } else logger . groupCollapsed ( title ) ;
8280 } else if ( colors . title && isUsingDefaultFormatter ) {
8381 logger . group ( `%c ${ title } ` , ...headerCSS ) ;
8482 } else {
@@ -94,23 +92,43 @@ function printBuffer(buffer, options) {
9492 const nextStateLevel = getLogLevel ( level , formattedAction , [ nextState ] , 'nextState' ) ;
9593
9694 if ( prevStateLevel ) {
97- if ( colors . prevState ) logger [ prevStateLevel ] ( '%c prev state' , `color: ${ colors . prevState ( prevState ) } ; font-weight: bold` , prevState ) ;
98- else logger [ prevStateLevel ] ( 'prev state' , prevState ) ;
95+ if ( colors . prevState ) {
96+ logger [ prevStateLevel ] (
97+ '%c prev state' ,
98+ `color: ${ colors . prevState ( prevState ) } ; font-weight: bold` ,
99+ prevState ,
100+ ) ;
101+ } else logger [ prevStateLevel ] ( 'prev state' , prevState ) ;
99102 }
100103
101104 if ( actionLevel ) {
102- if ( colors . action ) logger [ actionLevel ] ( '%c action ' , `color: ${ colors . action ( formattedAction ) } ; font-weight: bold` , formattedAction ) ;
103- else logger [ actionLevel ] ( 'action ' , formattedAction ) ;
105+ if ( colors . action ) {
106+ logger [ actionLevel ] (
107+ '%c action ' ,
108+ `color: ${ colors . action ( formattedAction ) } ; font-weight: bold` ,
109+ formattedAction ,
110+ ) ;
111+ } else logger [ actionLevel ] ( 'action ' , formattedAction ) ;
104112 }
105113
106114 if ( error && errorLevel ) {
107- if ( colors . error ) logger [ errorLevel ] ( '%c error ' , `color: ${ colors . error ( error , prevState ) } ; font-weight: bold;` , error ) ;
108- else logger [ errorLevel ] ( 'error ' , error ) ;
115+ if ( colors . error ) {
116+ logger [ errorLevel ] (
117+ '%c error ' ,
118+ `color: ${ colors . error ( error , prevState ) } ; font-weight: bold;` ,
119+ error ,
120+ ) ;
121+ } else logger [ errorLevel ] ( 'error ' , error ) ;
109122 }
110123
111124 if ( nextStateLevel ) {
112- if ( colors . nextState ) logger [ nextStateLevel ] ( '%c next state' , `color: ${ colors . nextState ( nextState ) } ; font-weight: bold` , nextState ) ;
113- else logger [ nextStateLevel ] ( 'next state' , nextState ) ;
125+ if ( colors . nextState ) {
126+ logger [ nextStateLevel ] (
127+ '%c next state' ,
128+ `color: ${ colors . nextState ( nextState ) } ; font-weight: bold` ,
129+ nextState ,
130+ ) ;
131+ } else logger [ nextStateLevel ] ( 'next state' , nextState ) ;
114132 }
115133
116134 if ( diff ) {
0 commit comments