This project is not covered by Drupal’s security advisory policy.
This module is an attempt to provide a way to log debug information and all SQL queries during SimpleTest test cases, and from within module code, in a better way than any other approach currently available.
Features
This module provides:
- A straightforward logging interface to use before, during, and after SimpleTest test cases via the new
tlds_log()method. It's a drop-in replacement forkpr(),dpm(), orprint_r(). - Optionally-timestamped log lines.
- Log output that can contain:
- All SQL queries executed by the database, with parameter substitutions automatically filled-in for you.
- Plain text debug messages.
- SQL query objects you pass-in manually (again, with automatic fill-in of parameter substitutions).
- Human-friendly and objects, generated using Leon Sorokin's excellent
dump_r()replacement forprint_r()andvar_dump(). Even handles resources, closures, and recursive references!
Approaches with Existing Modules
Prior to this module coming into existence, you might have pursued the following alternate approaches:
Drupal's debug() function
Provides a basic way to write out messages and simple structures in both tests and the Drupal messages area, but there are several limitations:
- Has a limit of 1,024 characters of debug output because it relies on the PHP trigger_error() function. Anything longer gets truncated or crashes the test.
- Is handled inconsistently throughout the test as a result of running everything through
trigger_error(). Sometimes the test reports the output as debug information, while other times it reports it as an error. The API doesn't seem consistent here. - Does not log all SQL queries (with their substitutions) for you.
Devel
Provides dpm() and other handy debug printing methods, but there are several limitations:
- Can only show you output if the page finishes loading and is captured by the SimpleTest browser.
- Using
dpm()seems to limit how much you can write out into a message without corrupting the messages area of the user's session / crashing the request after using up PHP memory. - Using
kpr()writes the output out above the page HTML rather than buffering debug output in memory, allowing you to write out more data before hitting the PHP memory limit, but this affects tests results because the HTML does not parse properly. - Does not log all SQL queries (with their substitutions) for you.
- Requires the user the test is logging-in as to have permission granted to view debug information.
- Relies on the buggy Krumo library that can sometimes influence the results of the code being debugged.
Drupal's watchdog() function
Not viable because SimpleTest runs everything in a separate copy of the site, so the watchdog DB log is not preserved.
Devel Debug Log
Not viable because SimpleTest runs everything in a separate copy of the site, so the DDL log is not preserved.
Manually Logging to a File
You could manually use file_put_contents() and print_r() or var_dump() to write out debug statements to a log.
This works but it clutters up your test and module logic with having to manage log files. TL;DS abstracts this out for you!
Project information
Unsupported
Not supported (i.e. abandoned), and no longer being developed. Learn more about dealing with unsupported (abandoned) projectsObsolete
Use of this project is deprecated.- Project categories: Developer tools
- Created by guypaddock on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
