Add configurable logger

This commit is contained in:
Kunal Karmakar
2026-03-21 05:18:25 +00:00
parent 6148ccc529
commit 92b7687068
8 changed files with 170 additions and 11 deletions
+5 -5
View File
@@ -23,16 +23,16 @@ func agentCmd(message, sessionKey, model string, debug bool) error {
sessionKey = "cli:default"
}
if debug {
logger.SetLevel(logger.DEBUG)
fmt.Println("🔍 Debug mode enabled")
}
cfg, err := internal.LoadConfig()
if err != nil {
return fmt.Errorf("error loading config: %w", err)
}
if debug {
logger.SetLevel(logger.DEBUG)
fmt.Println("🔍 Debug mode enabled")
}
if model != "" {
cfg.Agents.Defaults.ModelName = model
}
+7 -1
View File
@@ -5,6 +5,7 @@ import (
"path/filepath"
"github.com/sipeed/picoclaw/pkg/config"
"github.com/sipeed/picoclaw/pkg/logger"
)
const Logo = "🦞"
@@ -27,7 +28,12 @@ func GetConfigPath() string {
}
func LoadConfig() (*config.Config, error) {
return config.LoadConfig(GetConfigPath())
cfg, err := config.LoadConfig(GetConfigPath())
if err != nil {
return nil, err
}
logger.SetLevelFromString(cfg.Agents.Defaults.LogLevel)
return cfg, nil
}
// FormatVersion returns the version string with optional git commit