Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reorder levels #21

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions levels/levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ var (
type Level int8

const (
// NoLevel defines an absent log level.
NoLevel Level = iota + 1
// Disabled disables the logger.
Disabled
// TraceLevel defines trace log level.
TraceLevel
// Debug defines debug log level.
Debug Level = iota + 1
Debug
// Info defines info log level.
Info
// Warn defines warn log level.
Expand All @@ -37,28 +43,20 @@ const (
Fatal
// Panic defines panic log level.
Panic
// NoLevel defines an absent log level.
NoLevel
// Disabled disables the logger.
Disabled

// TraceLevel defines trace log level.
TraceLevel Level = -1
// Values less than TraceLevel are handled as numbers.
)

// String returns the string representation of the log level int.
func (l Level) String() string {
values := map[Level]string{
NoLevel: "",
Disabled: "disabled",
TraceLevel: TraceValue,
Debug: DebugValue,
Info: InfoValue,
Warn: WarnValue,
Error: ErrorValue,
Fatal: FatalValue,
Panic: PanicValue,
Disabled: "disabled",
NoLevel: "",
}

if value, exists := values[l]; exists {
Expand Down