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:
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...