Cleanup - centralize the log handling

This commit is contained in:
2024-08-27 12:16:01 -05:00
parent d8891ec75f
commit a6b7fc7afe
15 changed files with 124 additions and 180 deletions

View File

@@ -1,12 +1,13 @@
#!/bin/bash
#set -x
systemd-cat -t "`basename $0`" -p info <<< "Started"
. helpers.sh
log Started
./getNewAccessToken.sh
if [[ $? -ne 0 ]]; then
systemd-cat -t "`basename $0`" -p err <<< "Child process to get access token reported error. Exiting."
exit 1
log "Child process to get access token reported error. Exiting." err 1
fi
jq -r '.[].Symbol' allSymbols.json | sort | while read theSymbol; do
@@ -14,7 +15,7 @@ jq -r '.[].Symbol' allSymbols.json | sort | while read theSymbol; do
if [[ '$XSP' = ${theSymbol} ]]; then
./recordOptionChainSingleSymbolSingleRun.sh -ErrorAsWarning ${theSymbol} toDate $(date "+%Y-%m-%d" -d "+400 days")
if [[ $? -ne 0 ]]; then
systemd-cat -t "`basename $0`" -p warning <<< "falling back to stitching for ${theSymbol}"
log "falling back to stitching for ${theSymbol}" warning
./recordOptionChainSingleSymbolSpecialRun.sh ${theSymbol} toDate $(date "+%Y-%m-%d" -d "+400 days")
if [[ $? -ne 0 ]]; then
touch temp/hadErrors.$$.tmp
@@ -27,7 +28,7 @@ jq -r '.[].Symbol' allSymbols.json | sort | while read theSymbol; do
#Default behavior - fall back to stitching on error
./recordOptionChainSingleSymbolSingleRun.sh -ErrorAsWarning ${theSymbol}
if [[ $? -ne 0 ]]; then
systemd-cat -t "`basename $0`" -p warning <<< "falling back to stitching for ${theSymbol}"
log "falling back to stitching for ${theSymbol}" warning
./recordOptionChainSingleSymbolSpecialRun.sh ${theSymbol}
if [[ $? -ne 0 ]]; then
touch temp/hadErrors.$$.tmp
@@ -40,4 +41,4 @@ if [[ -e temp/hadErrors.$$.tmp ]]; then
curl -d "" -X POST "https://deadswitch.kawomi.com/api/v1?topic=trade.schwab.error.recordAllSymbolsSingleRun&secs=1&email=joe@kawomi.com"
fi
systemd-cat -t "`basename $0`" -p info <<< "Finished"
log "Finished"