X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/e45b0db3d66ca9e041622db3d801d026fb4d3724..b4d04354a46d9574d91b0892187e9e669ff03c21:/.zsh/logging diff --git a/.zsh/logging b/.zsh/logging index 65c9532..c23ad42 100644 --- a/.zsh/logging +++ b/.zsh/logging @@ -9,31 +9,29 @@ # __log() { + setopt localoptions noxtrace local level; level="$1"; shift echo "${level}: $@" >&2 } __do_debug() { + setopt localoptions noxtrace [ -n "${ZDEBUG:-}" ] } zerror() { - [[ -o xtrace ]] && set +x && local __XTRACE=1 + setopt localoptions noxtrace __log E "$@" - [ "${__XTRACE:-}" ] && set -x } zwarn() { - [[ -o xtrace ]] && set +x && local __XTRACE=1 + setopt localoptions noxtrace __log W "$@" - [ "${__XTRACE:-}" ] && set -x } zinfo() { - [[ -o xtrace ]] && set +x && local __XTRACE=1 + setopt localoptions noxtrace __log I "$@" - [ "${__XTRACE:-}" ] && set -x } zdebug() { - [[ -o xtrace ]] && set +x && local __XTRACE=1 + setopt localoptions noxtrace __do_debug && __log D "$@" - [ "${__XTRACE:-}" ] && set -x } # vim:ft=zsh