Last active
December 4, 2017 17:00
-
-
Save ssledz/8b3268b1e1097c74cd445f34f25615d2 to your computer and use it in GitHub Desktop.
bash lib : system out
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
#!/bin/bash | |
[[ -z $DBG ]] && DBG=0 | |
now() { | |
date +"%Y-%m-%d %H:%M:%S" | |
} | |
eecho() { | |
local label=$1 | |
shift | |
local msg= | |
if [[ $# == 0 ]]; then | |
msg=$(cat -) | |
else | |
msg="$*" | |
fi | |
echo -e "$label : "$msg | |
} | |
dbg() { | |
[[ $DBG == 1 ]] && (1>&2 eecho "[DEBUG]" $*) | |
} | |
info() { | |
eecho "$(now)" $* | |
} | |
warn() { | |
eecho "[WARN]" $* | |
} | |
err() { | |
(1>&2 eecho "[ERROR]" $*) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of usage: