-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to RPC for slog logger, and add some helpers for all defa… (
#114) * Add support to RPC for slog logger, and add some helpers for all default log levels to easily pass to the client option * Update usages of log. to the slog compatible logger * Update readme to show how to set up logging (and a bit of reorganization) * Update pkg/rpc/readme.md Co-authored-by: StartToaster <[email protected]> --------- Co-authored-by: StartToaster <[email protected]>
- Loading branch information
1 parent
71666e5
commit 79749b0
Showing
8 changed files
with
130 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/chia-network/go-chia-libs | ||
|
||
go 1.18 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/google/go-querystring v1.1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package rpcinterface | ||
|
||
import ( | ||
"log/slog" | ||
"os" | ||
) | ||
|
||
// SlogError returns a text handler preconfigured to ERROR log level | ||
func SlogError() slog.Handler { | ||
opts := &slog.HandlerOptions{ | ||
Level: slog.LevelError, | ||
} | ||
|
||
handler := slog.NewTextHandler(os.Stdout, opts) | ||
return handler | ||
} | ||
|
||
// SlogWarn returns a text handler preconfigured to WARN log level | ||
func SlogWarn() slog.Handler { | ||
opts := &slog.HandlerOptions{ | ||
Level: slog.LevelWarn, | ||
} | ||
|
||
handler := slog.NewTextHandler(os.Stdout, opts) | ||
return handler | ||
} | ||
|
||
// SlogInfo returns a text handler preconfigured to INFO log level | ||
func SlogInfo() slog.Handler { | ||
opts := &slog.HandlerOptions{ | ||
Level: slog.LevelInfo, | ||
} | ||
|
||
handler := slog.NewTextHandler(os.Stdout, opts) | ||
return handler | ||
} | ||
|
||
// SlogDebug returns a text handler preconfigured to DEBUG log level | ||
func SlogDebug() slog.Handler { | ||
opts := &slog.HandlerOptions{ | ||
Level: slog.LevelDebug, | ||
} | ||
|
||
handler := slog.NewTextHandler(os.Stdout, opts) | ||
return handler | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters