-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2279 from OffchainLabs/fix-log-level-opt
Change log-level cli opt to take a string
- Loading branch information
Showing
8 changed files
with
74 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024, Offchain Labs, Inc. | ||
// For license information, see https://github.com/nitro/blob/master/LICENSE | ||
|
||
package genericconf | ||
|
||
import ( | ||
"errors" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/ethereum/go-ethereum/log" | ||
"golang.org/x/exp/slog" | ||
) | ||
|
||
func ToSlogLevel(str string) (slog.Level, error) { | ||
switch strings.ToLower(str) { | ||
case "trace": | ||
return log.LevelTrace, nil | ||
case "debug": | ||
return log.LevelDebug, nil | ||
case "info": | ||
return log.LevelInfo, nil | ||
case "warn": | ||
return log.LevelWarn, nil | ||
case "error": | ||
return log.LevelError, nil | ||
case "crit": | ||
return log.LevelCrit, nil | ||
default: | ||
legacyLevel, err := strconv.Atoi(str) | ||
if err != nil { | ||
// Leave legacy geth numeric log levels undocumented, but if anyone happens | ||
// to be using them, it will work. | ||
return log.LevelTrace, errors.New("invalid log-level") | ||
} | ||
return log.FromLegacyLevel(legacyLevel), nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters