Last active
February 25, 2020 02:26
-
-
Save AlbertoDePena/9391b67069625799c60e26c2934009dd to your computer and use it in GitHub Desktop.
Thread safe, colored console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<RequireQualifiedAccess>] | |
module Console = | |
open System | |
let private log = | |
let lockObj = obj() | |
fun color text -> | |
lock lockObj (fun _ -> | |
Console.ForegroundColor <- color | |
printfn "%s" text | |
Console.ResetColor()) | |
let complete = log ConsoleColor.Magenta | |
let ok = log ConsoleColor.Green | |
let info = log ConsoleColor.Cyan | |
let warn = log ConsoleColor.Yellow | |
let error = log ConsoleColor.Red |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment