Download the PHP package brunoggdev/ci4-logging-extended without Composer
On this page you can find all versions of the php package brunoggdev/ci4-logging-extended. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brunoggdev/ci4-logging-extended
More information about brunoggdev/ci4-logging-extended
Files in brunoggdev/ci4-logging-extended
Package ci4-logging-extended
Short Description Extended logging for CodeIgniter 4: improved context serialization, exception() method with rich context, web-based Log Viewer with IDE deep links, and exception alerting.
License MIT
Informations about the package ci4-logging-extended
ci4-logging-extended
Extended logging for CodeIgniter 4 — part of the ci4-*-extended series.
Two things in one package:
php spark log:tail— Watch your log file in real time with colorized, filtered output.- Richer context serialization — CI4's native logger follows the PSR-3 spec strictly: context keys without a matching
{placeholder}in the message are silently discarded. This package extends that behavior by appending leftover keys askey=valuepairs automatically.
Installation
log:tail
On startup it shows the last 20 lines of today's log, then streams new entries as they arrive. Rolls over automatically at midnight when a new daily file is created.
Options
| Option | Description | Default |
|---|---|---|
-level |
Filter by log level | — |
-filter |
Filter lines containing this text (case-insensitive) | — |
-lines |
Lines to show on startup (use 0 to skip) |
20 |
Examples
Output
- Level is colorized: red for
error/critical/alert/emergency, yellow forwarning, cyan fornotice, green forinfo, gray fordebug - The context part (after
|) is highlighted in cyan to visually separate it from the main message
Context serialization
This package ships with Brunoggdev\LoggingExtended\Logger, an improved drop-in replacement for CI4's native logger, and a logger() helper function to quickly get an instance of it.
Wire it up by adding the following to app/Config/Services.php:
PSR-3 only interpolates context keys that have a matching {placeholder} in the message — everything else is discarded by design. With the extended logger, leftover keys are appended automatically:
With the extended logger wired in, the same call produces:
PSR-3 placeholder interpolation still works as before — keys consumed by {placeholders} are not duplicated in the appended context:
Logging exceptions
The extended logger adds an exception() method that formats a Throwable into a clean log entry:
Need to also send exceptions to an external tracker (Sentry, GlitchTip, etc.)? Extend the logger and override exception() — calling parent:: keeps the file log entry:
Then wire your subclass in app/Config/Services.php instead of the base one.
Using a custom Logger subclass?
If you have a class that extends CI4's Logger (e.g. SentryLogger, GoogleLogger), just swap the parent import and you get context serialization for free: