inspect
Log instructive and well formatted variable dumps and deep stack traces.
Inspect variables and stack traces, and get better error handling
- analyzes all kinds of variables, safely
- provides deep back traces and error traces
Doesn't show, doesn't fail - applicable in production
- Inspect always hides the value of object/array buckets keyed 'pass' and 'password'
- doesn't fail on dumping $GLOBALS (~ objects/arrays having self-referring values)
- doesn't fail on dumping large data structures, degrades gracefully*
* Inspectors and tracers stop before producing overly long output. And abort if time is closing in to PHP's maximum execution time.
D9/10 5.x
Simple usage
\Drupal::service('inspect.inspect')->variable($subject)->log('debug', 'Message prefix');
\Drupal::service('inspect.inspect')->trace($throwableOrNull)->log();
Works with Grafana and database log viewers
The settings form makes it easy to configure against file and database logging, respectively.
Documentation
Uses generic Inspect library
Depends on SimpleComplex Inspect, which depends on nothing.
Requirements
PHP ^8.1
D7 6.x
Tidy and manageable dump output
- expansible/collapsible branches, buttons for displaying
all descendants vs. immediate children - exhibits variable key paths, like
array['conf']['language_default']->language
Includes powerful frontend (Javascript) inspector
- inspect variables; and get full error stack tracing (except for IE)
- inspect jQuery events
- log frontend inspections and errors to the backend log
Don't worry anymore...
about forgotten var_dump()s and print_r()s after development and debugging sessions.
If you've set user role permissions sensibly: the ordinary site visitor will never see a dump.
* Inspectors and tracers stop - and do a second attempt using less depth+more truncation - when producing overly long output. And they abort if time is closing in to PHP's maximum execution time.
User/permissions suggestions
Manage who gets to see and log inspections via the module's user role permissions.
Direct inspection
- create 'tester' role
- allow 'tester's to log inspections/traces
- create user having the 'tester' role as well as the role relevant for the scenario you want to investigate (anonymous or authenticated user, or some dedicated user role)
- test the relevant pages/features, and check screen outputs or Recent log messages
Indirect inspection - gather information during users' visits
- allow the appropriate role to log inspections/traces
- do something else, for minutes/hours/days
- revoke the role's inspection permission (prevent log flooding)
- check Recent log messages and study the inspections gathered during real life use of your site
Sponsorship
Inspect version 7.x-5.0 was sponsored by Københavns Kommune, Koncernservice (Copenhagen Municipality, Corporate Services).
Related modules
- Devel
- Log Filter - a better log viewer
- JSONlog
Requirements
PHP 5.3+