Skip to content

Instantly share code, notes, and snippets.

@AlbertoDePena
Last active February 25, 2020 02:26
Show Gist options
  • Save AlbertoDePena/9391b67069625799c60e26c2934009dd to your computer and use it in GitHub Desktop.
Save AlbertoDePena/9391b67069625799c60e26c2934009dd to your computer and use it in GitHub Desktop.
Thread safe, colored console
[<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