diff options
author | Christian Hesse <mail@eworm.de> | 2021-01-20 17:06:34 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-01-22 09:22:34 +0100 |
commit | bbf918e32915d3b7b929ad3ecfff7d51968a9ad4 (patch) | |
tree | 1694dcb9ed988a7bcaaa55b0bdcbb648944e5e03 | |
parent | 086a395e8233b81f702884492c7edb11e5fd0c32 (diff) |
global-functions: $LogPrintExit: colorful output
-rw-r--r-- | global-functions | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/global-functions b/global-functions index c1311cf..d66541d 100644 --- a/global-functions +++ b/global-functions @@ -412,6 +412,11 @@ :global PrintDebug; + :local PrintSeverity do={ + :local Color { debug=96; info=97; warning=93; error=91 }; + :return ("\1B[" . $Color->$1 . "m" . $1 . "\1B[0m"); + } + :if ($Severity ~ "^(debug|error|info)\$") do={ :if ($Severity = "debug") do={ :log debug $Message; } :if ($Severity = "error") do={ :log error $Message; } @@ -423,9 +428,9 @@ :if ($Severity != "debug" || $PrintDebug = true) do={ :if ($Exit = "true") do={ - :error ($Severity . ": " . $Message); + :error ([ $PrintSeverity $Severity ] . ": " . $Message); } else={ - :put ($Severity . ": " . $Message); + :put ([ $PrintSeverity $Severity ] . ": " . $Message); } } } |