Skip to content
Snippets Groups Projects
Commit dbda2208 authored by Eric Schoville's avatar Eric Schoville
Browse files

Move JSON log formatting to function

parent c4b85705
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,21 @@ handle_term() { ...@@ -64,6 +64,21 @@ handle_term() {
fi fi
} }
set_json_log() {
if [ ! -z ${JSON_LOG} ]; then
# https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
# Replace the text line with a json formatted line. This is ugly.
find . -type f -name log4j.properties \
-exec sed -i '/^log4j.appender.stdout.layout.ConversionPattern/c\log4j.appender.stdout.layout.ConversionPattern={"dateIso8601":"%d","timeZone":"%d{z}","priority":"%p","category":"%c","message":"%m"}%n' \
{} \;
fi
}
# Login to the API with the provided username and password and get the URL and session id # Login to the API with the provided username and password and get the URL and session id
# so we can check the status of this agent. Read results into Bash array # so we can check the status of this agent. Read results into Bash array
...@@ -87,6 +102,14 @@ if [ -z "$status_code" ]; then ...@@ -87,6 +102,14 @@ if [ -z "$status_code" ]; then
exit 1 exit 1
fi fi
error_code=$(jq -nr "${json}|.error.code")
if [ -z "$error_code" ]; then
echo "Error connecting to Informatica API: ${error_code}"
echo $json
exit 1
fi
result=($(jq -nr "${json}|.serverUrl, .icSessionId")) result=($(jq -nr "${json}|.serverUrl, .icSessionId"))
if [ -z "$result" ]; then if [ -z "$result" ]; then
...@@ -146,8 +169,9 @@ else ...@@ -146,8 +169,9 @@ else
fi fi
# set shutdown hooks # set shutdown hooks and set the json log file if necessary
prep_term prep_term
set_json_log
# run application # run application
./infaagent startup ./infaagent startup
...@@ -190,16 +214,6 @@ curl -sS -H "Content-Type: application/json" \ ...@@ -190,16 +214,6 @@ curl -sS -H "Content-Type: application/json" \
term_child_pid=$(cat $PID_FILE) term_child_pid=$(cat $PID_FILE)
echoGreen "Secure Agent Starting pid:$term_child_pid" echoGreen "Secure Agent Starting pid:$term_child_pid"
if [[ -n ${JSON_LOG+x} && "$JSON_LOG" = true ]]; then
# https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
# Replace the text line with a json formatted line. This is ugly.
find . -type f -name log4j.properties \
-exec sed -i '/^log4j.appender.stdout.layout.ConversionPattern/c\log4j.appender.stdout.layout.ConversionPattern={"dateIso8601":"%d","timeZone":"%d{z}","priority":"%p","category":"%c","message":"%m"}%n' \
{} \;
fi
# wait until terminated # wait until terminated
while true while true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment