Replace logging system with slog and tint for structured colored output
- Add logger.go with public Logger variable and InitLogger function - Replace all fmt.Printf/fmt.Fprintf calls with structured Logger.Info/Logger.Error - Initialize logger in main function for consistent access across packages - Keep fmt.Errorf for proper error creation (standard Go practice) - Add tint dependency for colorized terminal output with timestamps - Convert user output to structured logging with key-value pairs - Update info command to use structured logging for plugin details - Update updateassets command to use structured progress logging - Update version command to use structured logging - Update authentication logging in client.go with structured fields - Update enable/disable commands to use structured logging - Remove unused fmt imports after conversion All output now uses slog with tint for beautiful, structured, colorized logging while maintaining proper error handling with fmt.Errorf for error creation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b43e7ac3ec
commit
73149001eb
11 changed files with 80 additions and 46 deletions
|
@ -15,6 +15,9 @@ const (
|
|||
)
|
||||
|
||||
func main() {
|
||||
// Initialize logger
|
||||
pluginctl.InitLogger()
|
||||
|
||||
var pluginPath string
|
||||
|
||||
flag.StringVar(&pluginPath, "plugin-path", "", "Path to plugin directory (overrides PLUGINCTL_PLUGIN_PATH)")
|
||||
|
@ -22,7 +25,7 @@ func main() {
|
|||
|
||||
args := flag.Args()
|
||||
if len(args) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error: No command specified\n\n")
|
||||
pluginctl.Logger.Error("No command specified")
|
||||
showUsage()
|
||||
os.Exit(ExitError)
|
||||
}
|
||||
|
@ -34,7 +37,7 @@ func main() {
|
|||
effectivePluginPath := pluginctl.GetEffectivePluginPath(pluginPath)
|
||||
|
||||
if err := runCommand(command, commandArgs, effectivePluginPath); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
pluginctl.Logger.Error("Command failed", "error", err)
|
||||
os.Exit(ExitError)
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +71,7 @@ func runInfoCommand(args []string, pluginPath string) error {
|
|||
|
||||
func runVersionCommand(_ []string) error {
|
||||
version := pluginctl.GetVersion()
|
||||
fmt.Printf("pluginctl version %s\n", version)
|
||||
pluginctl.Logger.Info("pluginctl version", "version", version)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -89,7 +92,7 @@ func runUpdateAssetsCommand(args []string, pluginPath string) error {
|
|||
}
|
||||
|
||||
func showUsage() {
|
||||
fmt.Printf(`pluginctl - Mattermost Plugin Development CLI
|
||||
usageText := `pluginctl - Mattermost Plugin Development CLI
|
||||
|
||||
Usage:
|
||||
pluginctl [global options] <command> [command options] [arguments...]
|
||||
|
@ -127,5 +130,6 @@ Environment Variables:
|
|||
|
||||
For more information about Mattermost plugin development, visit:
|
||||
https://developers.mattermost.com/integrate/plugins/
|
||||
`)
|
||||
`
|
||||
pluginctl.Logger.Info(usageText)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue