Skip to content

v2.3.0 — real log channels, working ignore_channels, self-publishing CP assets

Choose a tag to compare

@emran-alhaddad emran-alhaddad released this 27 Oct 11:47
· 3 commits to master since this release

Two user-reported fixes: #3 and #4.

No schema change and nothing to run. composer update is the whole upgrade.

composer require emran-alhaddad/statamic-logbook:^2.3

Fixed

System logs record the channel they actually came from (#3)

Every system-log row used to be stored with the channel logbook, and logbook.system_logs.ignore_channels matched nothing — the capture listener read $event->channel, and Illuminate\Log\Events\MessageLogged has no such property (it carries only level, message and context). Monolog's own $record->channel is no substitute either: Laravel names every Monolog logger $config['name'] ?? app.env, so a channel without an explicit name reports production.

Logbook now attaches a lazy Laravel log tap to each channel in config/logging.php, which labels that channel's records with its real name on the way through. A stack channel reports stack rather than one of its sub-channels, and the marker is stripped from the Monolog record before any handler runs, so nothing new appears in your own laravel.log.

The deprecations channel is covered too. Laravel only materialises its config the first time a deprecation fires — after addon boot — so Logbook seeds it the way the framework does, and the shipped ignore_channels => ['deprecations'] default finally drops deprecation rows as documented, NullHandler or not.

Channels the host registers after boot, and on-demand loggers from Log::build() / Log::stack(), carry no name Laravel can report; their records are still captured, under the logbook fallback.

vendor:publish --tag=logbook publishes something (#4)

The README has always documented that tag, but Statamic registers addon assets under the addon slug (statamic-logbook) and skips its own bootConfig() for a config file that is not named after the slug — so the documented command reported "No publishable resources for tag [logbook]". Three tags are now registered:

Tag Publishes
logbook config + CP stylesheet + CP script
logbook-assets CP stylesheet + CP script only (safe to --force)
logbook-config config/logbook.php only

The config stays out of the statamic-logbook tag on purpose: Statamic force-publishes that tag after statamic:install, which would overwrite an edited config/logbook.php on every composer update.

Added

CP assets publish themselves (#4)

Statamic only force-publishes addon assets from statamic:install, which plenty of deploys never run, and a composer update that ships a newer bundle leaves the old published copy in place — both of which surface as an unstyled Control Panel. Logbook now copies anything missing or stale into public/vendor/statamic-logbook/ on the first CP request of each process, then no-ops. It fails soft and silently on a read-only public/, and php artisan logbook:install publishes the bundles as well.

LOGBOOK_ASSETS_AUTO_PUBLISH=false (logbook.assets.auto_publish) turns the runtime copy off for immutable deploys — publish during the build instead:

php artisan vendor:publish --tag=logbook-assets --force

One behaviour change worth knowing about

If your app routes PHP deprecations through Log::channel('deprecations'), those rows stop being recorded, because ignore_channels now works and deprecations is in the shipped default. That was always the documented intent. To keep recording them:

LOGBOOK_SYSTEM_LOGS_IGNORE_CHANNELS=

Existing rows are untouched and keep their logbook channel. See UPGRADE.md for the full upgrade note, and CHANGELOG.md for the detail.

Full Changelog: v2.2.0...v2.3.0