Skip to content

Commit

Permalink
Merge branch 'master' into refactor-python-code
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Serra Scalet committed Jun 15, 2018
2 parents 79acd23 + b5653a1 commit 34504b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
18 changes: 11 additions & 7 deletions daisy/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,20 @@ func (w *Workflow) createLogger(ctx context.Context) {
return nil
})

if !w.gcsLoggingDisabled {
gcsLogger := NewGCSLogger(ctx, w.StorageClient, w.bucket, path.Join(w.logsPath, "daisy.log"))
l.gcsLogWriter = &syncedWriter{buf: bufio.NewWriter(gcsLogger)}
periodicFlush(func() { l.gcsLogWriter.Flush() })
}

if !w.cloudLoggingDisabled && w.cloudLoggingClient != nil {
// Verify we can communicate with the log service.
if err := w.cloudLoggingClient.Ping(ctx); err != nil {
w.LogWorkflowInfo("Unable to send logs to the Cloud Logging service, not sending logs: %v", err)
l.WriteLogEntry(&LogEntry{
LocalTimestamp: time.Now(),
WorkflowName: getAbsoluteName(w),
Message: fmt.Sprintf("Unable to send logs to the Cloud Logging service, not sending logs: %v", err),
})
w.cloudLoggingClient = nil
} else {
cloudLogName := fmt.Sprintf("daisy-%s-%s", w.Name, w.id)
Expand All @@ -70,12 +80,6 @@ func (w *Workflow) createLogger(ctx context.Context) {
}
}

if !w.gcsLoggingDisabled {
gcsLogger := NewGCSLogger(ctx, w.StorageClient, w.bucket, path.Join(w.logsPath, "daisy.log"))
l.gcsLogWriter = &syncedWriter{buf: bufio.NewWriter(gcsLogger)}
periodicFlush(func() { l.gcsLogWriter.Flush() })
}

w.Logger = l

w.addCleanupHook(func() dErr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ln -s ${CLOUDSDK_BIN_PATH}/git-credential-gcloud.sh /usr/bin/git-credential-gclo
for PROGRAM in bq gsutil gcloud; do
echo '#!/bin/bash' > /usr/bin/${PROGRAM}
echo 'source /opt/rh/python27/enable' >> /usr/bin/${PROGRAM}
echo "${CLOUDSDK_BIN_PATH}/${PROGRAM} \$@" >> /usr/bin/${PROGRAM}
echo "${CLOUDSDK_BIN_PATH}/${PROGRAM} \"\$@\"" >> /usr/bin/${PROGRAM}
chmod 755 /usr/bin/${PROGRAM}
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ ln -s ${CLOUDSDK_BIN_PATH}/git-credential-gcloud.sh /usr/bin/git-credential-gclo
for PROGRAM in bq gsutil gcloud; do
echo '#!/bin/bash' > /usr/bin/${PROGRAM}
echo 'source /opt/rh/python27/enable' >> /usr/bin/${PROGRAM}
echo "${CLOUDSDK_BIN_PATH}/${PROGRAM} \$@" >> /usr/bin/${PROGRAM}
echo "${CLOUDSDK_BIN_PATH}/${PROGRAM} \"\$@\"" >> /usr/bin/${PROGRAM}
chmod 755 /usr/bin/${PROGRAM}
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ln -s ${CLOUDSDK_BIN_PATH}/git-credential-gcloud.sh /usr/bin/git-credential-gclo
for PROGRAM in bq gsutil gcloud; do
echo '#!/bin/bash' > /usr/bin/${PROGRAM}
echo 'source /opt/rh/python27/enable' >> /usr/bin/${PROGRAM}
echo "${CLOUDSDK_BIN_PATH}/${PROGRAM} \$@" >> /usr/bin/${PROGRAM}
echo "${CLOUDSDK_BIN_PATH}/${PROGRAM} \"\$@\"" >> /usr/bin/${PROGRAM}
chmod 755 /usr/bin/${PROGRAM}
done

Expand Down

0 comments on commit 34504b9

Please sign in to comment.