summaryrefslogtreecommitdiff
path: root/src/logger.ts
blob: ffe8f51d08a26d7027cd7f79ebb436ccd315c33e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import type { IO } from "fp-ts/lib/IO";

export interface Logger {
  info: (message: string) => IO<void>;
  error: (message: string) => IO<void>;
  warn: (message: string) => IO<void>;
}

export const ConsoleLogger: Logger = {
  info: (message: string) => () =>
    console.log(`[${new Date().toUTCString()}] INFO ` + message),
  error: (message: string) => () =>
    console.error(`[${new Date().toUTCString()}] ERROR ` + message),
  warn: (message: string) => () =>
    console.warn(`[${new Date().toUTCString()}] WARN ` + message),
};