Skip to content

Commit 4ace559

Browse files
committed
Merge branch 'dev' into 4.0
2 parents fac84bc + e538a95 commit 4ace559

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: types/logger.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { 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+
38
export 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

1420
export function createLogger<S>(option?: LoggerOption<S>): Plugin<S>;

Diff for: types/test/index.ts

+8-1
Original file line numberDiff line numberDiff 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 }>({

0 commit comments

Comments
 (0)