]> git.donarmstrong.com Git - zsh.git/blob - .zsh/logging
add ~/.local/bin to PATH
[zsh.git] / .zsh / logging
1 # -*- mode: sh -*-
2 # logging
3 #
4 # Logging abilities for the shell initialisation scripts
5 #
6 # Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
7 # Released under the terms of the Artistic Licence 2.0
8 #
9 # Source repository: git://git.madduck.net/etc/zsh.git
10 #
11
12 __log() {
13   local level; level="$1"; shift
14   echo "${level}: $@" >&2
15 }
16 __do_debug() {
17   [ -n "${ZDEBUG:-}" ]
18 }
19 error() {
20   [[ -o xtrace ]] && set +x && local __XTRACE=1
21   __log E "$@" 
22   [ "${__XTRACE:-}" ] && set -x
23 }
24 warn() {
25   [[ -o xtrace ]] && set +x && local __XTRACE=1
26   __log W "$@" 
27   [ "${__XTRACE:-}" ] && set -x
28 }
29 info() {
30   [[ -o xtrace ]] && set +x && local __XTRACE=1
31   __log I "$@" 
32   [ "${__XTRACE:-}" ] && set -x
33 }
34 debug() {
35   [[ -o xtrace ]] && set +x && local __XTRACE=1
36   __do_debug && __log D "$@" 
37   [ "${__XTRACE:-}" ] && set -x
38 }
39
40 # vim:ft=zsh