Skip to content

Commit

Permalink
feat: add func Log on pacakge toplevel
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 23, 2024
1 parent 51dce8c commit 581d3ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ func WithContext(ctx context.Context) *Record {

// -------------------------- Add log messages with level -----------------------------

// Log logs a message with level
func Log(level Level, args ...any) { std.log(level, args) }

// Print logs a message at level PrintLevel
func Print(args ...any) { std.log(PrintLevel, args) }

Expand Down
1 change: 1 addition & 0 deletions slog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func TestTextFormatWithColor(t *testing.T) {
}

func printLogs(msg string) {
slog.Log(slog.TraceLevel, msg)
slog.Print(msg)
slog.Println(msg)
slog.Trace(msg)
Expand Down

0 comments on commit 581d3ba

Please sign in to comment.