This is working for me, using the latest Drush dev-master:
drush @dev ev 'watchdog("system", "test watchdog message.");'
What I am doing here is just calling the 'watchdog' function directly with the php-eval command, after bootstrapping a dev site. This should produce the same results as a watchdog function called from a module, and in fact I see the message logged in the Drupal admin/reports/dblog page.
Drush does install a watchdog handler, so that it can log the watchdog messages to the console in addition to the dblog page; however, many of these messages are ignored by Drush as uninteresting. To see the full range of watchdog messages that Drush sees, set the --watchdog flag to 'print':
drush @dev --watchdog=print ev 'watchdog("system", "another watchdog message.");'
You should see this message printed in the console, and it should also appear in the dblog page.
I'm not sure why you are not seeing anything in your dblog page, but you might try upgrading Drush (if you're running an old version), and try some of these commands and see what results you get. This should give you some indication of where the problem is, at least.
UPDATE:
It seems impossible that the Drush hook should be called, but that nothing should be added to the dblog. The watchdog function in core does nothing but call hooks:
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/watchdog/7
The actual database write happens in function dblog_watchdog(), which is in dblog.module. It invariantly writes the entry to the database.
The only guess I have at this point in time is that perhaps you have multisite set up, and Drush is targeting the wrong site or database when you call your menu hook via a drush command. drush status
might help determine if this is the case. Next step would be to put a breakpoint on dblog_watchdog(), or add some sort of print statement there and see what happens when you run your function from Drush.
hook_drush_command
? Reading briefly from here, I will venture to guess you have to callwatchdog()
inside this hook as well (after your import statements).-u
option. Does your menu callback call the watchdog as anon? What happens when you use the-u
option to call your function?function bunn_prod_manual_import_drush_help($command) { switch ($command) { case 'drush:prod-manual-importing': return dt('Import Product Manuals'); } } function bunn_prod_manual_import_drush_command() { $items = array(); $items['prod-manual-import'] = array( 'description' => "Import product manuals.", 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL, ); return $items; }