Skip to content

Commit

Permalink
update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLYC committed Nov 23, 2021
1 parent a4ef3fd commit ddeb7c7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 8 deletions.
6 changes: 6 additions & 0 deletions cmd/command/define.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ var defineCmd = &cobra.Command{
define.ContextKeyLocation: simpleCmdFlag.location,
define.ContextKeyCommandManaged: false,
})), "install failed")

define.Logger.Info("defined command", map[string]interface{}{
"name": simpleCmdFlag.name,
"version": simpleCmdFlag.version,
"location": simpleCmdFlag.location,
})
},
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/command/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ var installCmd = &cobra.Command{
define.ContextKeyLocation: simpleCmdFlag.location,
define.ContextKeyCommandManaged: true,
})), "install failed")

define.Logger.Info("installed command", map[string]interface{}{
"name": simpleCmdFlag.name,
"version": simpleCmdFlag.version,
"location": simpleCmdFlag.location,
})
},
}

Expand Down
11 changes: 4 additions & 7 deletions cmd/command/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import (
)

var listCmdFlag struct {
name string
version string
location string
activated bool
}

Expand All @@ -23,7 +20,7 @@ var listCmd = &cobra.Command{
runner := core.NewStepRunner(
core.NewDBClientMaker(),
core.NewSimpleCommandsQuerier(
listCmdFlag.name, listCmdFlag.version, listCmdFlag.location, listCmdFlag.activated,
simpleCmdFlag.name, simpleCmdFlag.version, simpleCmdFlag.location, listCmdFlag.activated,
),
core.NewCommandPrinter(),
)
Expand All @@ -40,7 +37,7 @@ func init() {
Cmd.AddCommand(listCmd)

flags := listCmd.Flags()
flags.StringVarP(&listCmdFlag.name, "name", "n", "", "command name")
flags.StringVarP(&listCmdFlag.version, "version", "v", "", "command version")
flags.StringVarP(&listCmdFlag.location, "location", "l", "", "command location")
flags.StringVarP(&simpleCmdFlag.name, "name", "n", "", "command name")
flags.StringVarP(&simpleCmdFlag.version, "version", "v", "", "command version")
flags.StringVarP(&simpleCmdFlag.location, "location", "l", "", "command location")
}
6 changes: 6 additions & 0 deletions cmd/command/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ var uninstallCmd = &cobra.Command{
define.ContextKeyName: simpleCmdFlag.name,
define.ContextKeyVersion: simpleCmdFlag.version,
})), "list failed")

define.Logger.Info("uninstalled command", map[string]interface{}{
"name": simpleCmdFlag.name,
"version": simpleCmdFlag.version,
"location": simpleCmdFlag.location,
})
},
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/command/unset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ var unsetCmd = &cobra.Command{
utils.ExitWithError(runner.Run(utils.SetIntoContext(cmd.Context(), map[define.ContextKey]interface{}{
define.ContextKeyName: simpleCmdFlag.name,
})), "deactivate failed")

define.Logger.Info("unset command", map[string]interface{}{
"name": simpleCmdFlag.name,
})
},
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/command/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ var useCmd = &cobra.Command{
define.ContextKeyVersion: simpleCmdFlag.version,
define.ContextKeyLocation: simpleCmdFlag.location,
})), "activate failed")

define.Logger.Info("used command", map[string]interface{}{
"name": simpleCmdFlag.name,
"version": simpleCmdFlag.version,
})
},
}

Expand Down
2 changes: 1 addition & 1 deletion core/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (r *StepRunner) Run(ctx context.Context) (err error) {
}

defer func(step Steper) {
logger.Info("step finished", map[string]interface{}{
logger.Debug("step finished", map[string]interface{}{
"step": step,
})

Expand Down

0 comments on commit ddeb7c7

Please sign in to comment.