@@ -34,8 +34,10 @@ package btclog
3434
3535import (
3636 "bytes"
37+ "context"
3738 "fmt"
3839 "io"
40+ "log/slog"
3941 "os"
4042 "runtime"
4143 "strings"
@@ -417,6 +419,63 @@ func (l *subLog) Criticalf(format string, args ...any) {
417419 }
418420}
419421
422+ // TraceS writes a structured log with the given message and key-value pair
423+ // attributes with LevelTrace to the log.
424+ //
425+ // This is part of the Logger interface implementation.
426+ func (l * subLog ) TraceS (_ context.Context , msg string , attrs ... any ) {
427+ l .Tracef (msg , attrs ... )
428+ }
429+
430+ // DebugS writes a structured log with the given message and key-value pair
431+ // attributes with LevelDebug to the log.
432+ //
433+ // This is part of the Logger interface implementation.
434+ func (l * subLog ) DebugS (_ context.Context , msg string , attrs ... any ) {
435+ l .Debugf (msg , attrs ... )
436+ }
437+
438+ // InfoS writes a structured log with the given message and key-value pair
439+ // attributes with LevelInfo to the log.
440+ //
441+ // This is part of the Logger interface implementation.
442+ func (l * subLog ) InfoS (_ context.Context , msg string , attrs ... any ) {
443+ l .Infof (msg , attrs ... )
444+ }
445+
446+ // WarnS writes a structured log with the given message and key-value pair
447+ // attributes with LevelWarn to the log.
448+ //
449+ // This is part of the Logger interface implementation.
450+ func (l * subLog ) WarnS (_ context.Context , msg string , err error , attrs ... any ) {
451+ if err != nil {
452+ attrs = append ([]any {slog .String ("err" , err .Error ())}, attrs ... )
453+ }
454+ l .Warnf (msg , attrs ... )
455+ }
456+
457+ // ErrorS writes a structured log with the given message and key-value pair
458+ // attributes with LevelError to the log.
459+ //
460+ // This is part of the Logger interface implementation.
461+ func (l * subLog ) ErrorS (_ context.Context , msg string , err error , attrs ... any ) {
462+ if err != nil {
463+ attrs = append ([]any {slog .String ("err" , err .Error ())}, attrs ... )
464+ }
465+ l .Errorf (msg , attrs ... )
466+ }
467+
468+ // CriticalS writes a structured log with the given message and key-value pair
469+ // attributes with LevelCritical to the log.
470+ //
471+ // This is part of the Logger interface implementation.
472+ func (l * subLog ) CriticalS (_ context.Context , msg string , err error , attrs ... any ) {
473+ if err != nil {
474+ attrs = append ([]any {slog .String ("err" , err .Error ())}, attrs ... )
475+ }
476+ l .Criticalf (msg , attrs ... )
477+ }
478+
420479// Level returns the current logging level
421480//
422481// This is part of the Logger interface implementation.
0 commit comments