-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.fs
More file actions
31 lines (31 loc) · 1.4 KB
/
Logger.fs
File metadata and controls
31 lines (31 loc) · 1.4 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
namespace C_Omega
module Logger =
type Logger =
{log : string -> unit}
static member Printn = {log = System.Console.WriteLine}
static member CPrintn background foreground =
{log =
(fun s ->
let b, f = System.Console.BackgroundColor, System.Console.ForegroundColor
System.Console.BackgroundColor <- background
System.Console.ForegroundColor <- foreground
System.Console.WriteLine s
System.Console.BackgroundColor <- b
System.Console.ForegroundColor <- f
)
}
static member MPrintn = {log = fun s -> lock stdout (fun() -> System.Console.WriteLine s)}
static member MCPrintn background foreground =
{log =
(fun s ->
lock stdout (fun () ->
let b, f = System.Console.BackgroundColor, System.Console.ForegroundColor
System.Console.BackgroundColor <- background
System.Console.ForegroundColor <- foreground
System.Console.WriteLine s
System.Console.BackgroundColor <- b
System.Console.ForegroundColor <- f
)
)
}
let logf (log:Logger) pfs = Printf.kprintf log.log pfs