Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: liran2000 <[email protected]>
  • Loading branch information
liran2000 committed Oct 22, 2024
1 parent f973199 commit 3377286
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions openfeature/hooks/logging_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ type LoggingHook struct {
}

func NewLoggingHook(includeEvaluationContext bool) (*LoggingHook, error) {
return NewCustomLoggingHook(slog.Default(), includeEvaluationContext)
return NewCustomLoggingHook(includeEvaluationContext, slog.Default())
}

func NewCustomLoggingHook(logger *slog.Logger, includeEvaluationContext bool) (*LoggingHook, error) {
func NewCustomLoggingHook(includeEvaluationContext bool, logger *slog.Logger) (*LoggingHook, error) {
return &LoggingHook{
logger: logger,
includeEvaluationContext: includeEvaluationContext,
Expand Down
8 changes: 4 additions & 4 deletions openfeature/hooks/logging_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCreateLoggingHookWithDefaultLoggerAndContextInclusion(t *testing.T) {

func TestLoggingHookInitializesCorrectly(t *testing.T) {
logger := slog.New(slog.NewJSONHandler(os.Stderr, nil))
hook, err := NewCustomLoggingHook(logger, true)
hook, err := NewCustomLoggingHook(true, logger)
if err != nil {
t.Error("expected no error")
}
Expand All @@ -40,7 +40,7 @@ func TestLoggingHookInitializesCorrectly(t *testing.T) {
}

func TestLoggingHookHandlesNilLoggerGracefully(t *testing.T) {
hook, err := NewCustomLoggingHook(nil, false)
hook, err := NewCustomLoggingHook(false, nil)
if err != nil {
t.Error("expected no error")
}
Expand All @@ -59,7 +59,7 @@ func TestLoggingHookLogsMessagesAsExpected(t *testing.T) {
handler := slog.NewJSONHandler(buf, &slog.HandlerOptions{Level: slog.LevelDebug})
logger := slog.New(handler)

hook, err := NewCustomLoggingHook(logger, false)
hook, err := NewCustomLoggingHook(false, logger)
if err != nil {
t.Error("expected no error")
}
Expand All @@ -73,7 +73,7 @@ func TestLoggingHookLogsMessagesAsExpectedIncludeEvaluationContext(t *testing.T)
handler := slog.NewJSONHandler(buf, &slog.HandlerOptions{Level: slog.LevelDebug})
logger := slog.New(handler)

hook, err := NewCustomLoggingHook(logger, true)
hook, err := NewCustomLoggingHook(true, logger)
if err != nil {
t.Error("expected no error")
}
Expand Down

0 comments on commit 3377286

Please sign in to comment.