Download the PHP package gd-75/simple-logger without Composer
On this page you can find all versions of the php package gd-75/simple-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gd-75/simple-logger
More information about gd-75/simple-logger
Files in gd-75/simple-logger
Package simple-logger
Short Description A simple PSR-3 compliant PHP logger
License MIT
Informations about the package simple-logger
SimpleLogger
Simple PSR-3 compliant logger; less than 200 SLOC and 4 files.
Only one dependency, psr/log
, use this package with confidence.
This was originally a library that I developed for my own projects, but I thought it might be worth sharing. If you have any comments or spot a bug, feel free to open an issue.
Tests will eventually come later.
Features
Global minimal log level
Define a global minimal log level, useful when switching from development (DEBUG) to development (INFO or even NOTICE).
Custom writers with individual minimal level
The default writer writes to local log files, but if you want something else, feel free to create a custom writer, implement a single method present in the SimpleLoggerWriterInterface
, pass it to the logger and you are good to go.
As and added bonus, you can define a higher minimal level per writer. For example: all the logs go to the log file and only the critical ones go through your custom writer.
Logger proxies
Useful when a prefix needs to be prepended to a log message, for example inside a service class or a controller. Instead of the log message being
[INFO] Blah
it becomes
[INFO][Context] Blah
This is done through the use of a lightweight wrapper class that references a single global SimpleLogger
instance, meaning you save on
- time: do not manually prefix your log message for each class
- resources: there is only one "heavy" instance of the logger and its writers, the proxies are, well, proxies
Installation
Usage
Some every-day use cases, if you think that one use case is missing and should be added, feel free to open an issue :)