Skip to main content
added 812 characters in body
Source Link
greg_1_anderson
  • 21.4k
  • 2
  • 38
  • 47

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.

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.

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.

Source Link
greg_1_anderson
  • 21.4k
  • 2
  • 38
  • 47

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.