Download the PHP package shikachuu/jogger without Composer
On this page you can find all versions of the php package shikachuu/jogger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jogger
Jogger :running:
PSR-3 compatible, opinionated logger library for PHP mostly based on the Go project rs/zerolog and the PHP project Seldaek/monolog.
This library has been built, because I mostly felt like interpolation for json log strings can't provide as much flexibility, and are harder to filter on than additional fields. Since the json syntax provides it, we should use it's full potential.
Install
Features and Examples
Time formats:
Jogger supports 2 types of date formats:
- ISO8601
$logger->setTimeFormatISO8601();
- Unix timestamp
$logger->setTimeFormatUnix();
Additional, chained fields:
Jogger, just like zerolog, supports a number of primitive types (int, float...) and non-primitive types (currently only array) as additional fields next to the almost standard
message
andtimestamp
. These fields are also chainable (they have fluent return values).
^ The log message of the code above is roughly going to look like this:
Exceptions:
Zerolog has the ability to add Golang errors to your log messages. Since in PHP we mostly use Exceptions,
Jogger has the ability to add any Exception that inherits from PHP's default \Exception
class.
^ This code's log message roughly going to look like this:
Output Plugins:
At this point I assume you noticed a pattern around line 9, there is an array with an Output. Jogger supports output plugins made by its users. In fact, it contains 4 by default:
NOOP
for 'no operation', useful for testing or mocking something.Stream
for files and any PHP stream.STDOUT
for utilizing PHP's stdout stream. It is based on theStream
Output.STDERR
for utilizing PHP's stderr stream. It is based on theStream
Output.
In the constructor's array you have the ability to provide the loglevel, so you can use different outputs for different levels.
The core library shikachuu/jogger
, currently does not accepts Pull Requests for more outputs,
but it provides an abstract base class to write your own solutions, and you are more than welcome to open a Pull Request to link your repository to the README file's plugins section.