Created
May 1, 2025 22:34
-
-
Save darksinge/6818cb16c1b76a7a440f12dc03c283cd to your computer and use it in GitHub Desktop.
Simple fish script with "logging" functions with `gum`
This file contains hidden or 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
| function on_error --on-event fish_command_error | |
| exit | |
| end | |
| set -l ORANGE "#F4AC45" | |
| set -l GREEN "#04B575" | |
| set -l PINK 212 | |
| set -l GREY 250 | |
| function _log | |
| if test (count $argv) -eq 1 | |
| echo "HERE 1" | |
| gum log --structured --time="timeonly" --level="info" $argv[1..-1] | |
| else | |
| echo "HERE 2" | |
| set level "$argv[1]" | |
| if test "$level" != info -a "$level" != error -a "$level" != debug | |
| set level info | |
| end | |
| gum log --structured --time="timeonly" --level="$level" $argv[2..-1] | |
| end | |
| end | |
| function _info | |
| _log info $argv | |
| end | |
| function _error | |
| _log error $argv | |
| end | |
| function _debug | |
| if test "$DEBUG" = 1 -o "$DEBUG" = true | |
| _log debug $argv | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment