createMockLogger.js.flow
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// @flow
import {
logLevels,
} from '../constants';
import type {
LoggerType,
MessageContextType,
MessageEventHandlerType,
TranslateMessageFunctionType,
} from '../types';
const createMockLogger = (onMessage: MessageEventHandlerType, parentContext?: MessageContextType): LoggerType => {
// eslint-disable-next-line id-length, unicorn/prevent-abbreviations, no-unused-vars
const log = (a, b, c, d, e, f, g, h, i, k) => {
//
};
log.adopt = async (routine) => {
return routine();
};
// eslint-disable-next-line no-unused-vars
log.child = (context: TranslateMessageFunctionType | MessageContextType): LoggerType => {
return createMockLogger(onMessage, parentContext);
};
log.getContext = (): MessageContextType => {
return {};
};
for (const logLevel of Object.keys(logLevels)) {
// eslint-disable-next-line id-length, unicorn/prevent-abbreviations
log[logLevel] = (a, b, c, d, e, f, g, h, i, k) => {
return log.child({
logLevel: logLevels[logLevel],
})(a, b, c, d, e, f, g, h, i, k);
};
}
// @see https://github.com/facebook/flow/issues/6705
// $FlowFixMe
return log;
};
export default createMockLogger;