Skip to content

Commit

Permalink
minor feedback (cadence-workflow#5776)
Browse files Browse the repository at this point in the history
Just making the logs both slightly more defensive and returning early where possible.
  • Loading branch information
davidporter-id-au authored Mar 11, 2024
1 parent 9bd6ca2 commit 646ac32
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions service/history/execution/mutable_state_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4812,30 +4812,39 @@ func (e *mutableStateBuilder) unixNanoToTime(
}

func (e *mutableStateBuilder) logInfo(msg string, tags ...tag.Tag) {
if e != nil && e.executionInfo != nil {
if e != nil {
return
}
if e.executionInfo != nil {
tags = append(tags, tag.WorkflowID(e.executionInfo.WorkflowID))
tags = append(tags, tag.WorkflowRunID(e.executionInfo.RunID))
tags = append(tags, tag.WorkflowDomainID(e.executionInfo.DomainID))
e.logger.Info(msg, tags...)
}
e.logger.Info(msg, tags...)
}

func (e *mutableStateBuilder) logWarn(msg string, tags ...tag.Tag) {
if e != nil && e.executionInfo != nil {
if e != nil {
return
}
if e.executionInfo != nil {
tags = append(tags, tag.WorkflowID(e.executionInfo.WorkflowID))
tags = append(tags, tag.WorkflowRunID(e.executionInfo.RunID))
tags = append(tags, tag.WorkflowDomainID(e.executionInfo.DomainID))
e.logger.Warn(msg, tags...)
}
e.logger.Warn(msg, tags...)
}

func (e *mutableStateBuilder) logError(msg string, tags ...tag.Tag) {
if e != nil && e.executionInfo != nil {
if e != nil {
return
}
if e.executionInfo != nil {
tags = append(tags, tag.WorkflowID(e.executionInfo.WorkflowID))
tags = append(tags, tag.WorkflowRunID(e.executionInfo.RunID))
tags = append(tags, tag.WorkflowDomainID(e.executionInfo.DomainID))
e.logger.Error(msg, tags...)
}
e.logger.Error(msg, tags...)
}

func (e *mutableStateBuilder) logDataInconsistency() {
Expand Down

0 comments on commit 646ac32

Please sign in to comment.