Book Image

Drush for Developers - Second Edition

By : Juan Pablo Novillo Requena, Juan P Novillo Requena
Book Image

Drush for Developers - Second Edition

By: Juan Pablo Novillo Requena, Juan P Novillo Requena

Overview of this book

Table of Contents (13 chapters)
Drush for Developers Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Keeping Database Configuration and Code Together
Index

Logging messages in Drush


Writing log entries helps in spotting flaws as you read the logs to find out where a bug might be. How much we should log messages and prepare to catch errors depends on the nature of the task. A good approach is that the more critical the task, the more logging and error checking it should do. However, overly verbose logging would make our logfiles huge and hard to read. It's better if we log just the minimum needed notices, and all the errors and warnings found.

Drush uses the drush_log() function. This function accepts different logging levels. Here are some of them:

  • success: This marks a successful message

  • error: This reports an error message

  • warning: This is used to alert about something unexpected

  • info: This is used to print additional information

Each of the preceding list has synonyms. For example, instead of success, you can also use ok, completed, or status. In order to keep things simple, we will just use the preceding levels in the following examples...