Download the PHP package tiny-blocks/http-logging without Composer
On this page you can find all versions of the php package tiny-blocks/http-logging. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tiny-blocks/http-logging
More information about tiny-blocks/http-logging
Files in tiny-blocks/http-logging
Package http-logging
Short Description PSR-15 middleware that logs HTTP request and response metadata with request duration.
License MIT
Homepage https://github.com/tiny-blocks/http-logging
Informations about the package http-logging
Http Logging
- Overview
- Installation
- How to use
- Wiring the middleware
- Correlated logs
- Customizing the clock
- License
- Contributing
Overview
Provides a PSR-15 middleware that records every inbound HTTP exchange. Before invoking the next handler, the
middleware logs the request method, URI, query parameters, and parsed body. After the handler runs, it logs the
response status code, decoded JSON body when present, and the elapsed duration in milliseconds. Successful
responses are logged at info level. Responses in the 4xx/5xx range are logged at error level.
Duration is measured through a TinyBlocks\Time\MonotonicClock and a Stopwatch, so the reading is unaffected
by wall-clock adjustments. When the request carries a correlation identifier (under the correlationId
attribute, as exposed by tiny-blocks/http-correlation-id),
every log entry produced by this middleware is automatically tagged with the correlation_id context key
through the CorrelatedLogger collaborator.
Installation
How to use
Wiring the middleware
Builds the middleware with a PSR-3 logger and processes a request through it.
Correlated logs
When this middleware runs downstream from CorrelationIdMiddleware, every log entry it emits carries the
request's correlation identifier under the correlation_id context key, with no extra plumbing.
Customizing the clock
Replaces the default SystemMonotonicClock with a custom monotonic clock (for example, a deterministic
clock in tests).
License
Http Logging is licensed under MIT.
Contributing
Please follow the contributing guidelines to contribute to the project.
All versions of http-logging with dependencies
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/log Version ^3.0
tiny-blocks/http Version ^7.0
tiny-blocks/http-correlation-id Version ^2.1
tiny-blocks/time Version ^2.6