I'm using drush to run test scripts agains my drupal 7 installation. Simply calling:

$ drush scr path/to/myScript.php

My script is using drupal_set_message() to output status of my test scripts.

My problem is the output is sorted by importance, like that:

Test 1339 failed.                [error]
Test 1338 failed.                [error]
Something strange happened!      [warning]
Test 1337 successful.            [status]
Script starting.                 [notice]
Script finished after 1234ms.    [notice]

Is there any way to sort the output of the messages by the time they get called in my script, it would look much more logical like that:

Script starting.                 [notice]
Test 1337 successful.            [status]
Test 1338 failed.                [error]
Something strange happened!      [warning]
Test 1339 failed.                [error]
Script finished after 1234ms.    [notice]

Is that possible somehow? Is drupal_set_message() the wrong approach? Any suggestions?

1 Answer 1


You can log your debugging messages in database using watchdog and you will find the logged message in order at "admin/reports/dtblog"

Updated: Check the document page, as for [status] , watchdog has $severity parameter to set the status for your message.Following values can be set as status for the logged message.

WATCHDOG_EMERGENCY: Emergency, system is unusable.
WATCHDOG_ALERT: Alert, action must be taken immediately.
WATCHDOG_CRITICAL: Critical conditions.
WATCHDOG_ERROR: Error conditions.
WATCHDOG_WARNING: Warning conditions.
WATCHDOG_NOTICE: (default) Normal but significant conditions.
WATCHDOG_INFO: Informational messages.
WATCHDOG_DEBUG: Debug-level messages.

As a simple example, check this

 watchdog('your_script_name', '!message', array('!message' => "something_happened"), WATCHDOG_ERROR);

the above will log message when called keeping severity as "error".

  • Good alternative, indeed, but there is no [status], isn't it? Debug, Info and Notice are only displayed in verbose mode.
    – q9f
    Commented Oct 7, 2013 at 10:31
  • please check the updated answer.
    – arpitr
    Commented Oct 7, 2013 at 10:47
  • Yeah, I've seen the severity levels. [debug] is only shown with --debug and both [info] & [notice] are shown with --verbose options set. I'm looking for the normal green drupal [status] without passing any verbose or debug options but that seems not to exist in watchdog() due to some strange RCF declarations. But thanks anyways for your reply, I think I can live with that.
    – q9f
    Commented Oct 7, 2013 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.