We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 255588f commit 556cdf6Copy full SHA for 556cdf6
scripts/log-levels.sh
@@ -0,0 +1,22 @@
1
+#!/bin/bash
2
+
3
+VERBOSE=false
4
+HOST="google.com"
5
+PID="$$"
6
+PROGRAM_NAME="$0"
7
+THIS_HOST=$(hostname)
8
9
+logit () {
10
+ local LOG_LEVEL=$1
11
+ shift
12
+ MSG=$@
13
+ TIMESTAMP=$(date +"%Y-%m-%d %T")
14
+ if [ $LOG_LEVEL = 'ERROR' ] || $VERBOSE
15
+ then
16
+ echo "${TIMESTAMP} ${THIS_HOST} ${PROGRAM_NAME}[${PID}]: ${LOG_LEVEL} ${MSG}"
17
+ fi
18
+}
19
20
+logit INFO "Processing data."
21
22
+fetch-data $HOST || logit ERROR "Could not fetch data from $HOST"
0 commit comments