How to log drush commands

×

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 569 of /homepages/46/d762693627/htdocs/dc/includes/menu.inc).
How to log drush commands

Here's a way I came up with for logging drush commands. This might be useful for troubleshooting server slowness.

Add the following block of code to the start of the drush command:

# Rangi: Log all drush commands
LOG_STR=`date --rfc-3339=seconds`
LOG_STR="$LOG_STR drush"
PARAMS=""
for a in ${BASH_ARGV[*]} ; do
  PARAMS="$a $PARAMS"
done
LOG_STR="$LOG_STR $PARAMS (`whoami`)"
echo $LOG_STR >>/var/log/drush

This will add lines like this to /var/log/drush:

2013-07-16 16:02:01+01:00 drush scr /root/server-log.php (root)
2013-07-16 16:02:01+01:00 drush --root=/var/www/phoenix -l http://www.attractionticketsdirect.de solr-index 200 (root)
2013-07-16 16:03:01+01:00 drush ev atd_stock_import_kofax_scans(); (root)
2013-07-16 16:03:01+01:00 drush scr /root/server-log.php (root)
2013-07-16 16:04:01+01:00 drush scr /root/server-log.php (root)
2013-07-16 16:04:01+01:00 drush --root=/var/www/phoenix -l http://www.attractionticketsdirect.ie solr-index 200 (root)
2013-07-16 16:04:01+01:00 drush --root=/var/www/phoenix -l http://www.attractionticketsdirect.de solr-index 200 (root)
2013-07-16 16:04:01+01:00 drush --root=/var/www/phoenix -l http://www.attraction-tickets-direct.co.uk solr-index 200 (root)
2013-07-16 16:04:01+01:00 drush --root=/var/www/phoenix -l http://www.parques-e-ingressos.com.br solr-index 200 (root)
2013-07-16 16:04:01+01:00 drush ev atd_stock_import_kofax_scans(); (root)
blog tag: