Skip to content

Commit 66ae547

Browse files
committed
chore: update logging format
1 parent 0708960 commit 66ae547

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

internal/pkg/pluginengine/change.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func execute(smgr statemanager.Manager, changes []*Change) map[string]error {
104104

105105
for i, c := range changes {
106106
log.Separatorf("Processing progress: %d/%d.", i+1, numOfChanges)
107-
log.Infof("Processing: %s(kind: %s) -> %s ...", c.Tool.Name, c.Tool.Plugin.Kind, c.ActionName)
107+
log.Infof("Processing: %s (%s) -> %s ...", c.Tool.Name, c.Tool.Plugin.Kind, c.ActionName)
108108

109109
var succeeded bool
110110
var err error
@@ -116,7 +116,7 @@ func execute(smgr statemanager.Manager, changes []*Change) map[string]error {
116116
if err != nil {
117117
succeeded = false
118118
}
119-
log.Infof("Tool's changes with filled inputs are: %s.", c.Tool.Options)
119+
log.Debugf("Tool's changes with filled inputs are: %s.", c.Tool.Options)
120120

121121
switch c.ActionName {
122122
case statemanager.ActionCreate:
@@ -161,8 +161,8 @@ func handleResult(smgr statemanager.Manager, change *Change) error {
161161
}()
162162

163163
if !change.Result.Succeeded {
164-
log.Errorf("The tool < %s/%s > %s failed.", change.Tool.Name, change.Tool.Plugin.Kind, change.ActionName)
165-
return fmt.Errorf("the tool < %s/%s > %s failed", change.Tool.Name, change.Tool.Plugin.Kind, change.ActionName)
164+
log.Errorf("The tool %s (%s) %s failed.", change.Tool.Name, change.Tool.Plugin.Kind, change.ActionName)
165+
return fmt.Errorf("the tool %s (%s) %s failed", change.Tool.Name, change.Tool.Plugin.Kind, change.ActionName)
166166
}
167167

168168
if change.ActionName == statemanager.ActionDelete {
@@ -173,7 +173,7 @@ func handleResult(smgr statemanager.Manager, change *Change) error {
173173
log.Debugf("Failed to delete state %s: %s.", key, err)
174174
return err
175175
}
176-
log.Successf("Plugin %s/%s delete done.", change.Tool.Name, change.Tool.Plugin.Kind)
176+
log.Successf("Plugin %s (%s) delete done.", change.Tool.Name, change.Tool.Plugin.Kind)
177177
return nil
178178
}
179179

internal/pkg/pluginengine/change_helper.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func changesForApply(smgr statemanager.Manager, cfg *configloader.Config) ([]*Ch
7979

8080
if state == nil {
8181
// tool not in the state, create, no need to Read resource before Create
82-
description := fmt.Sprintf("Tool < %s > found in config but doesn't exist in the state, will be created.", tool.Name)
82+
description := fmt.Sprintf("Tool %s (%s) found in config but doesn't exist in the state, will be created.", tool.Name, tool.Plugin.Kind)
8383
changes = append(changes, generateCreateAction(&tool, description))
8484
} else {
8585
if err := renderRefByDependency(&tool, cfg.Tools, smgr); err != nil {
@@ -88,7 +88,7 @@ func changesForApply(smgr statemanager.Manager, cfg *configloader.Config) ([]*Ch
8888
// tool found in the state
8989
if drifted(tool.Options, state.Options) {
9090
// tool's config differs from State's, Update
91-
description := fmt.Sprintf("Tool < %s > config drifted from the state, will be updated.", tool.Name)
91+
description := fmt.Sprintf("Tool %s (%s) config drifted from the state, will be updated.", tool.Name, tool.Plugin.Kind)
9292
changes = append(changes, generateUpdateAction(&tool, description))
9393
} else {
9494
// tool's config is the same as State's
@@ -101,15 +101,15 @@ func changesForApply(smgr statemanager.Manager, cfg *configloader.Config) ([]*Ch
101101

102102
if resource == nil {
103103
// tool exists in the state, but resource doesn't exist, Create
104-
description := fmt.Sprintf("Tool < %s > state found but it seems the tool isn't created, will be created.", tool.Name)
104+
description := fmt.Sprintf("Tool %s (%s) state found but it seems the tool isn't created, will be created.", tool.Name, tool.Plugin.Kind)
105105
changes = append(changes, generateCreateAction(&tool, description))
106106
} else if drifted(resource, state.Resource) {
107107
// resource drifted from state, Update
108-
description := fmt.Sprintf("Tool < %s > drifted from the state, will be updated.", tool.Name)
108+
description := fmt.Sprintf("Tool %s (%s) drifted from the state, will be updated.", tool.Name, tool.Plugin.Kind)
109109
changes = append(changes, generateUpdateAction(&tool, description))
110110
} else {
111111
// resource is the same as the state, do nothing
112-
log.Debugf("Tool < %s > is the same as the state, do nothing.", tool.Name)
112+
log.Debugf("Tool %s (%s) is the same as the state, do nothing.", tool.Name, tool.Plugin.Kind)
113113
}
114114
}
115115
}
@@ -144,7 +144,7 @@ func changesForDelete(smgr statemanager.Manager, cfg *configloader.Config) []*Ch
144144
if state == nil {
145145
continue
146146
}
147-
description := fmt.Sprintf("Tool < %s > will be deleted.", tool.Name)
147+
description := fmt.Sprintf("Tool %s (%s) will be deleted.", tool.Name, tool.Plugin.Kind)
148148
changes = append(changes, generateDeleteAction(&tool, description))
149149
tmpStates.Delete(statemanager.StateKeyGenerateFunc(&tool))
150150
}
@@ -160,7 +160,7 @@ func changesForForceDelete(smgr statemanager.Manager, cfg *configloader.Config)
160160

161161
for i := len(cfg.Tools) - 1; i >= 0; i-- {
162162
tool := cfg.Tools[i]
163-
description := fmt.Sprintf("Tool < %s > will be deleted.", tool.Name)
163+
description := fmt.Sprintf("Tool %s (%s) will be deleted.", tool.Name, tool.Plugin.Kind)
164164
changes = append(changes, generateDeleteAction(&tool, description))
165165
if err := smgr.DeleteState(statemanager.StateKeyGenerateFunc(&tool)); err != nil {
166166
log.Errorf("Failed to delete %s from state.", statemanager.StateKeyGenerateFunc(&tool))
@@ -178,7 +178,7 @@ func renderRefByDependency(tool *configloader.Tool, tools []configloader.Tool, s
178178
for _, dependency := range tool.DependsOn {
179179
dependencyChange := false
180180
for _, c := range tools {
181-
log.Debugf("====== Name: %s kind: %s dependency: %s =====", c.Name, c.Plugin.Kind, dependency)
181+
log.Debugf("====== Name: %s (%s) dependency: %s =====", c.Name, c.Plugin.Kind, dependency)
182182
if fmt.Sprintf("%s%s%s", c.Name, ".", c.Plugin.Kind) == dependency {
183183
state := smgr.GetState(statemanager.StateKeyGenerateFunc(&c))
184184
if drifted(c.Options, state.Options) {

0 commit comments

Comments
 (0)