forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.ts
37 lines (34 loc) · 980 Bytes
/
logger.ts
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
import { GoLogLevel, GoBridgeInterface } from './types'
const formatMessage = (...args: any[]): string =>
args
.map((e) => JSON.stringify(e))
.join(' ')
.replace(/\\"/g, '"')
const BridgeLogger = (bridge: GoBridgeInterface) => ({
log: (message?: any, ...opts: any[]): void =>
bridge.log({
level: GoLogLevel.debug,
message: formatMessage(message, ...opts),
}),
debug: (message?: any, ...opts: any[]): void =>
bridge.log({
level: GoLogLevel.debug,
message: formatMessage(message, ...opts),
}),
warn: (message?: any, ...opts: any[]): void =>
bridge.log({
level: GoLogLevel.warn,
message: formatMessage(message, ...opts),
}),
error: (message?: any, ...opts: any[]): void =>
bridge.log({
level: GoLogLevel.error,
message: formatMessage(message, ...opts),
}),
info: (message?: any, ...opts: any[]): void =>
bridge.log({
level: GoLogLevel.info,
message: formatMessage(message, ...opts),
}),
})
export default BridgeLogger