There are some really handy debugging features which it's worth knowing about.
Configuration
As Mahara ships, debug, info, warn an environ error messages are sent to your error log.
Environ message are also sent to screen.
The default settings for logging are in lib/config-defaults.php under the Logging Configuration section.
I tend to have my log levels set to LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG as below:
$cfg->log_dbg_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG; $cfg->log_info_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG; $cfg->log_warn_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG; $cfg->log_environ_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
Functions
You can then use the various log functions to log anything. Variables are printed in a sane format which is easy to read. It's really quite a breath of fresh air when you compare it to something as primitive as var_dump:
log_debug('hello'); log_info($object); log_warn($othervar); log_environ($yetanothervar);
Notes
Mahara uses javascript form submission all over the place and if you're trying to debug a form using javascript, the log mesages won't be printed to screen until you next load the page.
As a result, it's often really helpful to tail the apache error log a lot of the time.
No comments:
Post a Comment