Download the PHP package spazzmarticus/monolog-batchstreamhandler without Composer
On this page you can find all versions of the php package spazzmarticus/monolog-batchstreamhandler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spazzmarticus/monolog-batchstreamhandler
More information about spazzmarticus/monolog-batchstreamhandler
Files in spazzmarticus/monolog-batchstreamhandler
Package monolog-batchstreamhandler
Short Description Pushes a batch of records to a stream at once.
License MIT
Homepage https://github.com/SpazzMarticus/monolog-batchstreamhandler
Informations about the package monolog-batchstreamhandler
BatchStreamHandler
A Monolog handler that takes a batch of records and pushes them to a stream at once.
(Use ^2.0 or Monolog ^2.0 and ^1.0 for Monolog ^1.x)
Why
When logging calls to webservers I like all log records of one call grouped together. I changed the default StreamHandler
to handle only batches of records (handleBatch
) and write them to the stream at once - voilà the BatchStreamHandler
.
Installation
Install with
Usage
StreamHandler
vs BatchStreamHandler
The default StreamHandler
pushes each record to the stream immediatly. Even when put after a BufferHandler (which buffers records until flush()
is called) each record is processed and written to the stream seperatly.
Let's assume there are 3 parallel calls to the webserver A
, B
, C
The log looks something like:
And that makes it hard to look at what happend at a specific calls.
With the BatchStreamHandler
the log looks something like:
Which is still not superb, so I added enveloping with head and foot lines.
Now this looks like a log I can work with: