Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: introduce logger choice via slog #292

Merged
merged 6 commits into from
Apr 2, 2024
Merged

feat!: introduce logger choice via slog #292

merged 6 commits into from
Apr 2, 2024

Commits on Mar 27, 2024

  1. feat!: introduce logger choice via slog

    Historically brokerapi has required use of the
    [`lager`](https://github.com/cloudfoundry/lager) logger. In Go 1.21,
    structured logging was introduced into the Go standard library via the
    [`log/slog`](https://pkg.go.dev/log/slog) package, and `slog`
    [compatability was added](cloudfoundry/lager@4bf4955)
    to `lager`.
    
    `brokerapi` has been modified to require a `slog` logger to be passed
    rather than a `lager` logger. This allows users a choice of logger.
    Users who still want to use lager can easily do that using the
    lager/slog compatability:
    ```go
    logger := lager.NewLogger(name)
    brokerAPI := brokerapi.New(serviceBroker, slog.New(lager.NewHandler(logger)), credentials)
    ```
    
    And users who want to use `slog` or an `slog`-compatible logger can do
    that instead.
    
    A key advantage is that `lager` is no longer a dependency of this
    package, which simplifies package management for apps that use brokerapi
    and other libraries which use `lager`.
    blgm committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    8870aa5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    87497e4 View commit details
    Browse the repository at this point in the history
  3. chore: mostly use the blog logger internally

    Externally we take a *slog.Logger, but internally we wrap this
    almost everywhere
    blgm committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    1f81f5e View commit details
    Browse the repository at this point in the history
  4. feat: ensure public API consistently uses slog.Logger

    Previously some of the public API had been altered to take the
    (internal) Blog logger. This is not correct, so the public API should
    now consistely take a *slog.Logger, and a Blog logger now implements the
    slog.Handler interface so can easily be converted to a slog.Logger.
    blgm committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    c542983 View commit details
    Browse the repository at this point in the history
  5. chore: tidy up

    blgm committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    ecc0a23 View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2024

  1. address code review comment

    blgm committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    141d356 View commit details
    Browse the repository at this point in the history