wci-bash 0.20181204135618.0 → 0.20181204141227.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/include.d/functions.bash +62 -2
- data/lib/wci.bash +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6cd5af397b0c94cc0ba9a0a3326584d3c0faf1b
|
4
|
+
data.tar.gz: 64a9f5f3542f67b99cec55a25cb4050e6a532236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9250d8243c4e9f7ea52503f902ba8168b4d53f5abd85269048d321749eeac0add732b820542ef8f28e61d90d37ae39996dc905eec767fe091f5a1ccf42abd855
|
7
|
+
data.tar.gz: 7d0ab880d67324f56b50753a0dd86999ac10cb58bceed4bf428b69fd31801f23052c306df73cca4cd7a23edf77e39938a40fef62356b626cd16118793f6efbce
|
@@ -1,6 +1,66 @@
|
|
1
1
|
|
2
2
|
### function include file for wci-libs-bash
|
3
3
|
|
4
|
-
function
|
5
|
-
|
4
|
+
function log_error {
|
5
|
+
ERROR_MESSAGE="$1"
|
6
|
+
ERROR_MESSAGE=${ERROR_MESSAGE:-ERROR_MESSAGE NOT SET}
|
7
|
+
THIS_PID="$$"
|
8
|
+
THIS_PID=${THIS_PID:-THIS_PID NOT SET}
|
9
|
+
SCRIPT_NAME=${SCRIPT_NAME:-SCRIPT_NAME NOT SET}
|
10
|
+
LOG_TIMESTAMP=`date "+%F %H:%M:%S %z"`
|
11
|
+
echo "${LOG_TIMESTAMP} - ${THIS_PID} - ${SCRIPT_NAME} - ERROR: ${ERROR_MESSAGE}" >&2
|
12
|
+
}
|
13
|
+
|
14
|
+
function log_error_line {
|
15
|
+
ERROR_MESSAGE="$1"
|
16
|
+
echo "${ERROR_MESSAGE}" >&2
|
17
|
+
}
|
18
|
+
|
19
|
+
function usage {
|
20
|
+
ERROR_MESSAGE="$1"
|
21
|
+
ERROR_MESSAGE=${ERROR_MESSAGE:-ERROR_MESSAGE NOT SET}
|
22
|
+
SCRIPT_NAME=${SCRIPT_NAME:-SCRIPT_NAME NOT SET}
|
23
|
+
EXIT_STATUS="1"
|
24
|
+
SLEEP_DURATION="3"
|
25
|
+
log_error_line
|
26
|
+
log_error "##### ***** ERROR ***** ######"
|
27
|
+
log_error
|
28
|
+
log_error "Message: ${ERROR_MESSAGE}"
|
29
|
+
log_error "CMD: ${SCRIPT_NAME} ${THIS_ARGS}"
|
30
|
+
if [ ! -z "${USAGE_INFO}" ] ; then
|
31
|
+
log_error
|
32
|
+
log_error "Usage: ${SCRIPT_NAME} ${USAGE_INFO}"
|
33
|
+
log_error
|
34
|
+
fi
|
35
|
+
log_error "##### ***** ERROR ***** ######"
|
36
|
+
log_error "##### Sleeping for ${SLEEP_DURATION} seconds then exiting with status: ${EXIT_STATUS}"
|
37
|
+
log_error_line
|
38
|
+
sleep "${SLEEP_DURATION}"
|
39
|
+
exit "${EXIT_STATUS}"
|
40
|
+
}
|
41
|
+
|
42
|
+
function log_event {
|
43
|
+
if [ "${WCI_ENABLE_LOGGING}" == "TRUE" ] ; then
|
44
|
+
LOG_MESSAGE="$1"
|
45
|
+
THIS_PID="$$"
|
46
|
+
THIS_PID=${THIS_PID:-THIS_PID NOT SET}
|
47
|
+
SCRIPT_NAME=${SCRIPT_NAME:-SCRIPT_NAME NOT SET}
|
48
|
+
LOG_TIMESTAMP=`date "+%F %H:%M:%S %z"`
|
49
|
+
echo "${LOG_TIMESTAMP} - ${THIS_PID} - ${SCRIPT_NAME} - ${LOG_MESSAGE}"
|
50
|
+
fi
|
51
|
+
}
|
52
|
+
|
53
|
+
function log_line {
|
54
|
+
if [ "${WCI_ENABLE_LOGGING}" == "TRUE" ] ; then
|
55
|
+
LOG_MESSAGE="$1"
|
56
|
+
echo "${LOG_MESSAGE}"
|
57
|
+
fi
|
58
|
+
}
|
59
|
+
|
60
|
+
function log_pipe {
|
61
|
+
while read LINE ; do
|
62
|
+
if [ "${WCI_ENABLE_LOGGING}" == "TRUE" ] ; then
|
63
|
+
echo "${LINE}"
|
64
|
+
fi
|
65
|
+
done < "/dev/stdin"
|
6
66
|
}
|
data/lib/wci.bash
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
|
2
2
|
### index include file for wci-libs-bash
|
3
3
|
|
4
|
-
|
4
|
+
WCI_LIBS_BASH_INSTALLED='TRUE'
|
5
|
+
|
6
|
+
### enable wci logging functionality
|
7
|
+
WCI_ENABLE_LOGGING="${WCI_ENABLE_LOGGING:-TRUE}"
|
5
8
|
|
6
9
|
ENTRY_SYMLINK_PATH="$(which wci.bash)"
|
7
10
|
ENTRY_PATH="$(realpath "${ENTRY_SYMLINK_PATH}")"
|