presprog / kirby-monolog
Use the Monolog logger library with Kirby CMS
Installs: 170
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:kirby-plugin
Requires
- getkirby/composer-installer: ^1.2
- monolog/monolog: ^3.3
- psr/log: ^3.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.42
README
This plugin adds the Monolog logging library to Kirby.
⚡ Ready for Kirby 4!
🤟Usage
Use the monolog()
helper function:
// Write to the default log file monolog()->log('something happend 😱'); // Log to another channel (only changes the filename for now) // Will log to "your-log-dir/other-channel-$date.log" monolog('other-channel')->log('something happend 😱'); // Change the log level (any of \Psr\Log\LogLevel) monolog()->log('something CRITICAL happend 😱', 'critical'); // …
If you throw and handle exceptions in your own code, you may log them with site()->logException()
:
try { // .. } catch(\Exception $exception) { site()->logException($exception) }
This will log the exception message with critical
level alongside the stack trace.
The plugin also automatically listens to Kirby system.exception
hook and logs the exception message as well as the stacktrace to the default log file.
💻 How to install
via Composer (recommended)
$ composer require presprog/kirby-monolog:^0.1
via ZIP archive
Download the ZIP archive, extract it into your plugins folder (defaults to site/plugins
) and rename the subfolder to monolog
.
✅ To do
- Define more channels via the config file
- …
Alternatives
There are plenty of alternatives:
- bnomei/monolog by Bruno Meilick (This one also integrates Monolog)
- johannschopplich/kirbylog by Johann Schopplich (This one is dependency-free!)
- michnhokn/logger by Michael Scheurich
- bvdputte/log by Bert Vandeputte
Made with ♥️ and ☕ by Present Progressive