Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fix/ub 1325 adda action name to the logs (#219)
Browse files Browse the repository at this point in the history
this PR will add an action name to each log line. (for example all oprerations that are part of Delete will have the request-action name in the log.
like : fd5dd389-7acb-11e8-88cd-54ee75515403-Delete )
  • Loading branch information
olgashtivelman authored Jul 15, 2018
1 parent d7a5c54 commit 490b484
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func main() {
panic(fmt.Errorf("Failed to setup log dir"))
}
}

defer utils.InitUbiquityServerLogger()()

logger := logs.GetLogger()
oldLogger := utils.SetupOldLogger("ubiquity")

Expand Down
1 change: 1 addition & 0 deletions resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,5 @@ type FlexVolumeDetachRequest struct {

type RequestContext struct {
Id string
ActionName string
}
23 changes: 15 additions & 8 deletions utils/logs/go_logging_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,21 @@ func (l *goLoggingLogger) getContextStringFromGoid() string {
go_id := GetGoID()
context, exists := GoIdToRequestIdMap.Load(go_id)
if !exists {
context = resources.RequestContext{Id: "NA"}
} else {
context = context.(resources.RequestContext)
context = resources.RequestContext{Id: "NA", ActionName: "NA"}
}

new_context := context.(resources.RequestContext)
if new_context.ActionName == "" {
new_context.ActionName = "NA"
}
if l.params.ShowGoid {
return fmt.Sprintf("%s:%d", context.(resources.RequestContext).Id, go_id)
if new_context.Id == "" {
new_context.Id = "NA"
}

if l.params.ShowGoid{
return fmt.Sprintf("%s:%d-%s", new_context.Id, go_id, new_context.ActionName)
} else {
return fmt.Sprintf("%s", context.(resources.RequestContext).Id)
return fmt.Sprintf("%s-%s", new_context.Id, new_context.ActionName)
}
}

Expand Down Expand Up @@ -149,7 +156,7 @@ func getLevel(level Level) logging.Level {
}
}

func GetNewRequestContext() resources.RequestContext {
func GetNewRequestContext(actionName string) resources.RequestContext{
request_uuid := fmt.Sprintf("%s", uuid.NewUUID())
return resources.RequestContext{Id: request_uuid}
return resources.RequestContext{Id: request_uuid, ActionName : actionName}
}

0 comments on commit 490b484

Please sign in to comment.