Last active
January 9, 2018 08:41
-
-
Save T1T4N/5f3264b174acd521b6f84682b2ce32fd to your computer and use it in GitHub Desktop.
Simple bash logging to a file
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
#!/usr/bin/env bash | |
readonly LOG_FILE="/tmp/$(basename "$0").log" | |
log_i() { echo "[INFO] $*" | tee -a "$LOG_FILE" >&2; } | |
log_w() { echo "[WARNING] $*" | tee -a "$LOG_FILE" >&2; } | |
log_e() { echo "[ERROR] $*" | tee -a "$LOG_FILE" >&2; } | |
log_f() { echo "[FATAL] $*" | tee -a "$LOG_FILE" >&2; return 1; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment