Cleanup - centralize the log handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
. helpers.sh
|
||||
outDir=data/$(date +%Y-%m-%d)
|
||||
mkdir -p "${outDir}"
|
||||
mkdir -p temp
|
||||
@@ -23,8 +24,7 @@ while [[ $# -gt 0 ]]; do
|
||||
shift; shift
|
||||
done
|
||||
|
||||
msg="Querying for Symbol: _${symbol}_ query string: _${queryString}_"
|
||||
systemd-cat -t "`basename $0` $1" -p debug <<< ${msg}
|
||||
log "Querying for Symbol: _${symbol}_ query string: _${queryString}_" debug
|
||||
|
||||
curl -s -X GET "https://api.schwabapi.com/marketdata/v1/chains${queryString}" \
|
||||
-H "Authorization: Bearer $(<access_token.dat)" > temp/optionChain.${symbol}.tmp.$$.json
|
||||
@@ -33,11 +33,11 @@ jqQuery=".symbol"
|
||||
symbolCheck=$(jq -r ${jqQuery} < temp/optionChain.${symbol}.tmp.$$.json)
|
||||
if [[ "${symbol}" != "${symbolCheck}" ]]; then
|
||||
errMsg="ERROR: THE RESPONSE IS INCORRECT! Symbol: _${symbol}_ Check: _${symbolCheck}_ check file _temp/optionChain.${symbol}.tmp.$$.json_"
|
||||
systemd-cat -t "`basename $0` $1" -p ${ErrorLogLevel} <<< ${errMsg}
|
||||
if [[ "${ErrorLogLevel}" == "err" ]]; then
|
||||
>&2 echo "${errMsg}"
|
||||
throw ${errMsg} ${ErrorLogLevel} 2
|
||||
else
|
||||
log ${errMsg} ${ErrorLogLevel}
|
||||
fi
|
||||
exit 2
|
||||
else
|
||||
optionChainFileName=$(date "+%Y-%m-%d %H_%M_%S")_optionChain.${symbol}.json
|
||||
#echo writing to file "${outDir}/${optionChainFileName}"
|
||||
|
||||
Reference in New Issue
Block a user