1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | export as namespace ReduxLogger;
|
8 |
|
9 | import * as Redux from 'redux';
|
10 |
|
11 | export const logger: Redux.Middleware;
|
12 |
|
13 | export type LoggerPredicate = (
|
14 | getState: () => any,
|
15 | action: any,
|
16 | logEntry?: LogEntryObject
|
17 | ) => boolean;
|
18 |
|
19 | export type StateToString = (state: any) => string;
|
20 | export type ActionToString = (action: any) => string;
|
21 | export type ErrorToString = (error: any, prevState: any) => string;
|
22 |
|
23 | export interface ColorsObject {
|
24 | title?: boolean | ActionToString | undefined;
|
25 | prevState?: boolean | StateToString | undefined;
|
26 | action?: boolean | ActionToString | undefined;
|
27 | nextState?: boolean | StateToString | undefined;
|
28 | error?: boolean | ErrorToString | undefined;
|
29 | }
|
30 |
|
31 | export interface LevelObject {
|
32 | prevState?: string | boolean | StateToString | undefined;
|
33 | action?: string | boolean | ActionToString | undefined;
|
34 | nextState?: string | boolean | StateToString | undefined;
|
35 | error?: string | boolean | ErrorToString | undefined;
|
36 | }
|
37 |
|
38 | export interface LogEntryObject {
|
39 | action?: string | boolean | ActionToString | undefined;
|
40 | started?: number | undefined;
|
41 | startedTime?: Date | undefined;
|
42 | took?: number | undefined;
|
43 | error?(error: any): any;
|
44 | nextState?(state: any): any;
|
45 | prevState?(state: any): any;
|
46 | }
|
47 |
|
48 | export interface ReduxLoggerOptions {
|
49 | level?: string | ActionToString | LevelObject | undefined;
|
50 | duration?: boolean | undefined;
|
51 | timestamp?: boolean | undefined;
|
52 | colors?: ColorsObject | false | undefined;
|
53 | titleFormatter?(formattedAction: any, formattedTime: string, took: number): string;
|
54 | logger?: any;
|
55 | logErrors?: boolean | undefined;
|
56 | collapsed?: boolean | LoggerPredicate | undefined;
|
57 | predicate?: LoggerPredicate | undefined;
|
58 | diff?: boolean | undefined;
|
59 | diffPredicate?: LoggerPredicate | undefined;
|
60 | stateTransformer?(state: any): any;
|
61 | actionTransformer?(action: any): any;
|
62 | errorTransformer?(error: any): any;
|
63 | }
|
64 |
|
65 | export function createLogger(options?: ReduxLoggerOptions): Redux.Middleware;
|
66 |
|
67 | export default logger;
|