Skip to content

Commit

Permalink
handle empty level in setupLogger
Browse files Browse the repository at this point in the history
Signed-off-by: Kit Patella <[email protected]>
  • Loading branch information
mkcp committed Oct 21, 2024
1 parent 7bb59c5 commit b0c378b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func init() {

// setup Logger handles creating a logger and setting it as the global default.
func setupLogger(level, format string) (*slog.Logger, error) {
// If we didn't get a level from config, fallback to "info"
if level == "" {
level = "info"
}
sLevel, err := logger.ParseLevel(level)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var validLevels = map[Level]bool{

// strLevels maps a string to its Level.
var strLevels = map[string]Level{
// NOTE(mkcp): We're mapping trace to debug for backwards compatibility.
// NOTE(mkcp): Map trace to debug for backwards compatibility.
"trace": Debug,
"debug": Debug,
"info": Info,
Expand Down

0 comments on commit b0c378b

Please sign in to comment.