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

Bugfix/log entry set fields #38

Merged
merged 3 commits into from
Jul 16, 2024

Commits on Apr 23, 2024

  1. Configuration menu
    Copy the full SHA
    c61752e View commit details
    Browse the repository at this point in the history
  2. LogEntrySetFields: Use the varargs syntax to supply the additional lo…

    …g arguments correctly
    
    Without the change in this changeset, running `go test` fails with:
    
    ```
    ./httplog.go:361:37: slog.Logger.With arg "attrs" should be a string or a slog.Attr (possible missing key or value)
    FAIL
    ```
    
    This is due to the fact that the array of `slog.Attr`s was supplied as
    a single arg (i.e. a single slice of attributes) to
    `*entry.Logger.With`, instead of a variable number of arguments.
    
    Example:
    
    ```go
    fields := map[string]any{
            "remote": "example.com",
            "action": "update",
    }
    httplog.LogEntrySetFields(ctx, fields)
    ```
    
    Without this change, the updated example that uses LogEntrySetFields
    creates the following log entry:
    
    ```
    user: "user1" !BADKEY: [remote=example.com action=update]
    ```
    
    With the change the log line for the updated example is:
    
    ```
    user: "user1" remote: "example.com" action: "update"
    ```
    stefansaasen committed Apr 23, 2024
    Configuration menu
    Copy the full SHA
    bceac34 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    dae0025 View commit details
    Browse the repository at this point in the history