This repository was archived by the owner on Jun 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.fs
More file actions
38 lines (31 loc) · 1.23 KB
/
Log.fs
File metadata and controls
38 lines (31 loc) · 1.23 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
(* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. *)
module Log
open System
type Level =
| Trace
| Debug
| Info
| Warning
| Error
| Fatal
let private colorRed = "\u001b[31m"
let private colorBlue = "\u001b[34m"
let private colorOff = "\u001b[0m"
let private prefix = function
| Trace -> "[ " + colorBlue + "\\" + colorOff + "]"
| Debug -> "[ " + colorBlue + "\\\\" + colorOff + "]"
| Info -> "[ " + colorBlue + "\\\\\\" + colorOff + "]"
| Warning -> "[ " + colorRed + "\\" + colorBlue + "\\\\\\" + colorOff + "]"
| Error -> "[ " + colorRed + "\\\\" + colorBlue + "\\\\\\" + colorOff + "]"
| Fatal -> "[" + colorRed + "\\\\\\\\\\\\" + colorOff + "]"
let private write lv =
printf "%s " (prefix lv)
printfn
let trace fmt = write Trace fmt
let debug fmt = write Debug fmt
let info fmt = write Info fmt
let warning fmt = write Warning fmt
let error fmt = write Error fmt
let fatal fmt = write Fatal fmt