about summary refs log tree commit diff
path: root/src/logger/bitdriftTransport.ts
blob: c2235e0d4b28613e5a02259389f72201fe9c7438 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import {
  debug as bdDebug,
  error as bdError,
  info as bdInfo,
  warn as bdWarn,
} from '@bitdrift/react-native'

import {LogLevel, Transport} from './types'

export function createBitdriftTransport(): Transport {
  const logFunctions = {
    [LogLevel.Debug]: bdDebug,
    [LogLevel.Info]: bdInfo,
    [LogLevel.Log]: bdInfo,
    [LogLevel.Warn]: bdWarn,
    [LogLevel.Error]: bdError,
  } as const

  return (level, message) => {
    const log = logFunctions[level]
    log(message.toString())
  }
}