Skip to content

Commit

Permalink
rename: CloudLoggingHandlerOptions to Options
Browse files Browse the repository at this point in the history
  • Loading branch information
s4s7 committed May 17, 2024
1 parent c4a8050 commit b71bc23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Special thanks to nownabe.
3. **You can initialize slog with a one-liner at server startup, allowing you to use its default slog methods throughout your application**

```golang
slog.SetDefault(slog.New(soglog.NewCloudLoggingHandler("your-project-id", &CloudLoggingHandlerOptions{IsStackTraced: true, LabelFieldInjector: yourLabelFieldInjector})
slog.SetDefault(slog.New(soglog.NewCloudLoggingHandler("your-project-id", &soglog.Options{IsStackTraced: true, LabelFieldInjector: yourLabelFieldInjector})
```

## Note
Expand Down
11 changes: 5 additions & 6 deletions soglog.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ type CloudLoggingHandler struct {

type labelFieldInjector func(ctx context.Context) (key, value string, found bool)

// CloudLoggingHandlerOptions defines the configuration options for creating a CloudLoggingHandler.
// This struct provides options to enable stack tracing and to inject custom label fields.
type CloudLoggingHandlerOptions struct {
// Options struct provides options to enable stack tracing and to inject custom label fields.
type Options struct {

// IsStackTraced indicates whether to include a stack trace in error logs.
// If set to true, a stack trace will be added to the log entries when the log level is Error.
Expand All @@ -55,10 +54,10 @@ type CloudLoggingHandlerOptions struct {
// NewCloudLoggingHandler creates a new CloudLoggingHandler with optional settings.
// If no options are provided, stack traces will not be included in error logs and no additional label fields will be injected.
// Example usage:
// slog.SetDefault(slog.New(soglog.NewCloudLoggingHandler("your-project-id", &CloudLoggingHandlerOptions{IsStackTraced: true, LabelFieldInjector: yourLabelFieldInjector})
func NewCloudLoggingHandler(projectID string, options ...*CloudLoggingHandlerOptions) *CloudLoggingHandler {
// slog.SetDefault(slog.New(soglog.NewCloudLoggingHandler("your-project-id", &soglog.Options{IsStackTraced: true, LabelFieldInjector: yourLabelFieldInjector})
func NewCloudLoggingHandler(projectID string, options ...*Options) *CloudLoggingHandler {

opts := &CloudLoggingHandlerOptions{}
opts := &Options{}
if len(options) > 0 {
opts = options[0]
}
Expand Down

0 comments on commit b71bc23

Please sign in to comment.