One of the improvements in http://drupal.org/project/provision is a flexible logging API we designed, to communicate back to the front end.
The logging infrastructure is modeled on the drupal_set_message functionality, and additionally integrates with those functions, when available, what it does, is allow you to set log messages to be displayed to the user, or communicated to the back end using a serialized string.
Messages are logged by calling (this has been drushified for the example)
drush_log('error', dt('Something has gone very very wrong'));
drush_log('warning', dt('There were some issues, but we can work with it'));
drush_log('notice', dt('You should know something'));
If not being run in the back end, this would print out the error messages immediately as they are logged, but if called from another drush script, it will store all the messages.
I would like to see this integrated with bash colours : http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html , so you can see if things go wrong.
Comment | File | Size | Author |
---|---|---|---|
#4 | drush_logging.diff | 3.68 KB | adrian |
#3 | drush_logging.diff | 3.68 KB | adrian |
Comments
Comment #1
adrian CreditAttribution: adrian commentedThis code is already fully formed in provision, but needs to be integrated into drush.
Comment #2
mlncn CreditAttribution: mlncn commentedWhat needs to happen in Drush– just take some code from Provision?
Comment #3
adrian CreditAttribution: adrian commentedHere is a patch for the logging API.
it differs slightly from the version in provision, and also takes on some of the characteristics of drush_error.
The 'notice' type will not display if you are not in verbose mode, by default all warnings and errors will display.
This also stays logged so it can be retrieved later. (by a calling script for instance).
I have not converted all the drush_error occurrences, because they need to be replaced by another the drush_set_error command, which will in turn call drush_log with the applicable error message.(http://drupal.org/node/212323)
Comment #4
adrian CreditAttribution: adrian commentedStupid typo in the last patch.
this one actually compiles =).
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted.