Skip to content

Allow http.handlers to add field to log output #5336

@WeidiDeng

Description

@WeidiDeng

Handlers should be able to add field to server log output for debugging and extending functionality purpose.

Currently when a http.handler can only emit log using its own logger provisioned when creating an instance of the module. A module can attach some context information to the request handled.

Currently caddy tries to determine user_id from basicauth. However if it's not configured it will be empty and people maybe confused by its presence. (Commonly, most usage of caddy is just reverse proxy and file server.). Trying from the entry ServeHttp function is simply too much to maintain for every handler module that caddy is shipped with.

A recent pr will also add a new field to determine client_ip and it's also available as a variable.

Allow http.handlers to add custom fields to log can help generate logs that are easier to analyse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussion 💬The right solution needs to be found

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions