File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { Payload , Plugin } from "./index" ;
2
2
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
+
3
8
export interface LoggerOption < S > {
4
9
collapsed ?: boolean ;
5
10
filter ?: < P extends Payload > ( mutation : P , stateBefore : S , stateAfter : S ) => boolean ;
@@ -9,6 +14,7 @@ export interface LoggerOption<S> {
9
14
actionTransformer ?: < P extends Payload > ( action : P ) => any ;
10
15
logMutations ?: boolean ;
11
16
logActions ?: boolean ;
17
+ logger ?: Logger ;
12
18
}
13
19
14
20
export function createLogger < S > ( option ?: LoggerOption < S > ) : Plugin < S > ;
Original file line number Diff line number Diff line change @@ -455,10 +455,17 @@ namespace Plugins {
455
455
} ) ;
456
456
}
457
457
458
+ class MyLogger {
459
+ log ( message : string ) {
460
+ console . log ( message ) ;
461
+ }
462
+ }
463
+
458
464
const logger = Vuex . createLogger < { value : number } > ( {
459
465
collapsed : true ,
460
466
transformer : state => state . value ,
461
- mutationTransformer : ( mutation : { type : string } ) => mutation . type
467
+ mutationTransformer : ( mutation : { type : string } ) => mutation . type ,
468
+ logger : new MyLogger ( )
462
469
} ) ;
463
470
464
471
const store = new Vuex . Store < { value : number } > ( {
You can’t perform that action at this time.
0 commit comments