Skip to content

Commit 62ddc70

Browse files
committed
fix: lint issues
1 parent 2660c82 commit 62ddc70

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

json.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (l *Logger) jsonFormatterItem(jw *jsonWriter, key, value any) {
8080
}
8181

8282
func (l *Logger) writeSlogValue(jw *jsonWriter, v slogValue) {
83-
switch v.Kind() {
83+
switch v.Kind() { //nolint:exhaustive
8484
case slogKindGroup:
8585
jw.start()
8686
for _, attr := range v.Group() {
@@ -139,7 +139,7 @@ func (w *jsonWriter) writeEncoded(v any) error {
139139
e := json.NewEncoder(w.w)
140140
e.SetEscapeHTML(false)
141141
if err := e.Encode(v); err != nil {
142-
return err
142+
return fmt.Errorf("failed to encode value: %w", err)
143143
}
144144

145145
// trailing \n added by json.Encode

level.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727

2828
// String returns the string representation of the level.
2929
func (l Level) String() string {
30-
switch l {
30+
switch l { //nolint:exhaustive
3131
case DebugLevel:
3232
return "debug"
3333
case InfoLevel:

logger.go

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ func (l *Logger) handle(level Level, ts time.Time, frames []runtime.Frame, msg i
129129
l.logfmtFormatter(kvs...)
130130
case JSONFormatter:
131131
l.jsonFormatter(kvs...)
132+
case TextFormatter:
133+
fallthrough
132134
default:
133135
l.textFormatter(kvs...)
134136
}

stdlog.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func (l *stdLogWriter) Write(p []byte) (n int, err error) {
1414
str := strings.TrimSuffix(string(p), "\n")
1515

1616
if l.opt != nil {
17-
switch l.opt.ForceLevel {
17+
switch l.opt.ForceLevel { //nolint:exhaustive
1818
case DebugLevel:
1919
l.l.Debug(str)
2020
case InfoLevel:

text.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (l *Logger) writeIndent(w io.Writer, str string, indent string, newline boo
2121
// kindly borrowed from hclog
2222
for {
2323
nl := strings.IndexByte(str, '\n')
24-
if nl == -1 {
24+
if nl == -1 { //nolint:nestif
2525
if str != "" {
2626
_, _ = w.Write([]byte(indent))
2727
val := escapeStringForOutput(str, false)

0 commit comments

Comments
 (0)