Skip to content

feat(sprigin): allow custom logger to be pass to sprigin#170

Open
42atomys wants to merge 5 commits intomainfrom
168-proposal-sprigin-custom-logger
Open

feat(sprigin): allow custom logger to be pass to sprigin#170
42atomys wants to merge 5 commits intomainfrom
168-proposal-sprigin-custom-logger

Conversation

@42atomys
Copy link
Member

@42atomys 42atomys commented Feb 2, 2026

Description

This PR allow user of sprigin to use a custom logger to link sprigin errors to internal logging system.

Changes

  • Add non-breaking variadic arg option pattern to allow customize the logger.

Fixes #168

Checklist

  • I have read the CONTRIBUTING.md document.
  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation accordingly.
  • This change requires a change to the documentation on the website.

@42atomys 42atomys linked an issue Feb 2, 2026 that may be closed by this pull request
1 task
@42atomys 42atomys requested a review from ccoVeille February 2, 2026 12:38
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sprigin/sprig_backward_compatibility.go 88.2% 1 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
sprigin/options.go 100.0% <100.0%> (ø)
sprigin/sprig_backward_compatibility.go 96.6% <88.2%> (-1.7%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@42atomys 42atomys requested a review from ccoVeille February 7, 2026 02:57
@42atomys
Copy link
Member Author

42atomys commented Feb 7, 2026

Comments addressed, thanks for your time @ccoVeille 🙏

Comment on lines +49 to +53
t.Run("works without options", func(t *testing.T) {
funcMap := FuncMap()

assert.NotNil(t, funcMap)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By reading only the PR (not only this test), and not the rest if the code, I'm a but surprised by the apparent simplicity of the tests here.

Is there any case when FuncMap will return something that is not nil?

I mean I feel like there is something strange with either FuncMap signature or the way you test it.

If your test is only there to validate the function signature. You don't need testify.

Also, here this test sounds strange. Why is the TestWithLogger testing something that is not using WithLogger it's about FuncMap

Comment on lines +42 to +46
customLogger := slog.New(slog.NewTextHandler(&buf, nil))

funcMap := FuncMap(WithLogger(customLogger))

assert.NotNil(t, funcMap)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment, this is not a test.

If you wanted a test, you should check something like funcMap contains/can use the custom logger

Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
Signed-off-by: Atomys <contact@atomys.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal: sprigin custom logger

2 participants