Skip to content

Document logging via the http: injection point #7

Description

@lineoffligbot

Logging already works. It is just not documented anywhere.

API#initialize accepts http:, and API#http chains onto whatever it is given
(@http.headers(...).use(:auto_inflate)), so any http.rb feature composes:

require "logger"

AmazonAds::Campaigns.new(
  region: "NA",
  access_token:,
  profile_id: "123456789",
  http: HTTP.use(logging: { logger: Logger.new($stdout) }),
)

Confirmed against http 6.0.4, which ships HTTP::Features::Logging. The
instrumentation feature is available the same way for ActiveSupport::Notifications.

Proposal

Document this in the README rather than adding a logger: keyword. A dedicated
kwarg would duplicate an existing seam and give us two ways to do the same thing.

The docs should carry an explicit warning: HTTP::Features::Logging writes all
request headers at debug level, which includes Authorization: Bearer <token>.
Anyone enabling debug logging against production is putting live access tokens in
their logs.

Worth deciding whether that warning is enough or whether we should ship a small
redacting wrapper alongside it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions