-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add colors to error/success/info messages (#118)
Move Logger to it's own module and make log out text with different color values.
Showing
4 changed files
with
48 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Logger | ||
|
||
open System | ||
|
||
let consoleColor (fc : ConsoleColor) = | ||
let current = Console.ForegroundColor | ||
Console.ForegroundColor <- fc | ||
{ new IDisposable with | ||
member x.Dispose() = Console.ForegroundColor <- current } | ||
|
||
let stringFormatter str = Printf.StringFormat<_, unit>(str) | ||
let informationfn str = Printf.kprintf (fun s -> use c = consoleColor ConsoleColor.Cyan in printfn "%s" s) str | ||
let errorfn str = Printf.kprintf (fun s -> use c = consoleColor ConsoleColor.Red in printfn "%s" s) str | ||
let okfn str = Printf.kprintf (fun s -> use c = consoleColor ConsoleColor.Green in printfn "%s" s) str |