Skip to content

Commit 0b6333a

Browse files
committed
log: group "enum" consts and touch-up docs
Also updated the level descriptions with their documentation from logrus. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 4a36022 commit 0b6333a

1 file changed

Lines changed: 38 additions & 25 deletions

File tree

log/context.go

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,42 @@ var (
3434
L = logrus.NewEntry(logrus.StandardLogger())
3535
)
3636

37-
type (
38-
loggerKey struct{}
37+
type loggerKey struct{}
3938

40-
// Fields type to pass to `WithFields`, alias from `logrus`.
41-
Fields = logrus.Fields
39+
// Fields type to pass to "WithFields".
40+
type Fields = logrus.Fields
4241

43-
// Level is a logging level
44-
Level = logrus.Level
45-
)
46-
47-
const (
48-
// RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to
49-
// ensure the formatted time is always the same number of characters.
50-
RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
42+
// RFC3339NanoFixed is [time.RFC3339Nano] with nanoseconds padded using
43+
// zeros to ensure the formatted time is always the same number of
44+
// characters.
45+
const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
5146

52-
// TextFormat represents the text logging format
53-
TextFormat = "text"
47+
// Level is a logging level.
48+
type Level = logrus.Level
5449

55-
// JSONFormat represents the JSON logging format
56-
JSONFormat = "json"
57-
58-
// TraceLevel level.
59-
TraceLevel = logrus.TraceLevel
50+
// Supported log levels.
51+
const (
52+
// TraceLevel level. Designates finer-grained informational events
53+
// than [DebugLevel].
54+
TraceLevel Level = logrus.TraceLevel
6055

61-
// DebugLevel level.
62-
DebugLevel = logrus.DebugLevel
56+
// DebugLevel level. Usually only enabled when debugging. Very verbose
57+
// logging.
58+
DebugLevel Level = logrus.DebugLevel
6359

64-
// InfoLevel level.
65-
InfoLevel = logrus.InfoLevel
60+
// InfoLevel level. General operational entries about what's going on
61+
// inside the application.
62+
InfoLevel Level = logrus.InfoLevel
6663
)
6764

68-
// SetLevel sets log level globally.
65+
// SetLevel sets log level globally. It returns an error if the given
66+
// level is not supported.
67+
//
68+
// level can be one of:
69+
//
70+
// - "trace" ([TraceLevel])
71+
// - "debug" ([DebugLevel])
72+
// - "info" ([InfoLevel])
6973
func SetLevel(level string) error {
7074
lvl, err := logrus.ParseLevel(level)
7175
if err != nil {
@@ -81,7 +85,16 @@ func GetLevel() Level {
8185
return logrus.GetLevel()
8286
}
8387

84-
// SetFormat sets log output format
88+
// Supported log output formats.
89+
const (
90+
// TextFormat represents the text logging format.
91+
TextFormat = "text"
92+
93+
// JSONFormat represents the JSON logging format.
94+
JSONFormat = "json"
95+
)
96+
97+
// SetFormat sets the log output format ([TextFormat] or [JSONFormat]).
8598
func SetFormat(format string) error {
8699
switch format {
87100
case TextFormat:

0 commit comments

Comments
 (0)