File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 11import { Payload , Plugin } from "./index" ;
22
3+ interface Logger extends Partial < Pick < Console , 'groupCollapsed' | 'group' | 'groupEnd' > > {
4+ log ( message : string , color : string , payload : any ) : void ;
5+ log ( message : string ) : void ;
6+ }
7+
38export interface LoggerOption < S > {
49 collapsed ?: boolean ;
510 filter ?: < P extends Payload > ( mutation : P , stateBefore : S , stateAfter : S ) => boolean ;
@@ -9,6 +14,7 @@ export interface LoggerOption<S> {
914 actionTransformer ?: < P extends Payload > ( action : P ) => any ;
1015 logMutations ?: boolean ;
1116 logActions ?: boolean ;
17+ logger ?: Logger ;
1218}
1319
1420export function createLogger < S > ( option ?: LoggerOption < S > ) : Plugin < S > ;
Original file line number Diff line number Diff line change @@ -455,10 +455,17 @@ namespace Plugins {
455455 } ) ;
456456 }
457457
458+ class MyLogger {
459+ log ( message : string ) {
460+ console . log ( message ) ;
461+ }
462+ }
463+
458464 const logger = Vuex . createLogger < { value : number } > ( {
459465 collapsed : true ,
460466 transformer : state => state . value ,
461- mutationTransformer : ( mutation : { type : string } ) => mutation . type
467+ mutationTransformer : ( mutation : { type : string } ) => mutation . type ,
468+ logger : new MyLogger ( )
462469 } ) ;
463470
464471 const store = new Vuex . Store < { value : number } > ( {
You can’t perform that action at this time.
0 commit comments