diff --git a/Mage/Console.php b/Mage/Console.php index b9dd97c..8dd7940 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -48,6 +48,12 @@ class Console */ private static $logEnabled = true; + /** + * Enables or disables verbose logging + * @var boolean + */ + private static $verboseLogEnabled = false; + /** * String Buffer for the screen output * @var string @@ -107,6 +113,8 @@ class Console self::$logEnabled = $config->general('logging', false); } + self::$verboseLogEnabled = self::isVerboseLoggingEnabled(); + // Greetings if ($showGreetings) { if (!self::$logEnabled) { @@ -173,15 +181,17 @@ class Console { self::log(strip_tags($message)); - self::$screenBuffer .= str_repeat("\t", $tabs) - . strip_tags($message) - . str_repeat(PHP_EOL, $newLine); + if (!self::$verboseLogEnabled) { + self::$screenBuffer .= str_repeat("\t", $tabs) + . strip_tags($message) + . str_repeat(PHP_EOL, $newLine); - $output = str_repeat("\t", $tabs) - . Colors::color($message, self::$config) - . str_repeat(PHP_EOL, $newLine); + $output = str_repeat("\t", $tabs) + . Colors::color($message, self::$config) + . str_repeat(PHP_EOL, $newLine); - echo $output; + echo $output; + } } /** @@ -227,6 +237,10 @@ class Console $message = date('Y-m-d H:i:s -- ') . $message; fwrite(self::$log, $message . PHP_EOL); + + if (self::$verboseLogEnabled) { + echo $message . PHP_EOL; + } } } @@ -286,4 +300,15 @@ class Console } } + /** + * Check if verbose logging is enabled + * @return boolean + */ + protected static function isVerboseLoggingEnabled() + { + return self::$config->getParameter('verbose', false) + || self::$config->general('verbose_logging') + || self::$config->environmentConfig('verbose_logging', false); + } + } diff --git a/docs/commands.txt b/docs/commands.txt index b9674b4..178bad2 100644 --- a/docs/commands.txt +++ b/docs/commands.txt @@ -51,9 +51,11 @@ mage releases rollback --release=-3 to:production # Rollback to a specific Release on the Production environment # mage releases rollback --release=20120101172148 to:production +# Output logs by adding verbose option to ANY command +mage deploy to:production --verbose ### List of UPCOMING Commands ### # mage config add host s05.example.com to:[production] # mage config git git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git # mage config svn svn://example.com/repo -# mage task:deployment/rsync to:production \ No newline at end of file +# mage task:deployment/rsync to:production diff --git a/docs/example-config/.mage/config/environment/production.yml b/docs/example-config/.mage/config/environment/production.yml index 5122d7d..97a3fcc 100644 --- a/docs/example-config/.mage/config/environment/production.yml +++ b/docs/example-config/.mage/config/environment/production.yml @@ -21,3 +21,4 @@ tasks: - privileges - sampleTask - sampleTaskRollbackAware +verbose_logging: true diff --git a/docs/example-config/.mage/config/environment/staging.yml b/docs/example-config/.mage/config/environment/staging.yml index 5c1c51d..51f4f06 100644 --- a/docs/example-config/.mage/config/environment/staging.yml +++ b/docs/example-config/.mage/config/environment/staging.yml @@ -29,3 +29,4 @@ tasks: # - sampleTask post-deploy: - sampleTask +verbose_logging: false diff --git a/docs/example-config/.mage/config/general.yml b/docs/example-config/.mage/config/general.yml index 3834ff3..c3a9b6d 100644 --- a/docs/example-config/.mage/config/general.yml +++ b/docs/example-config/.mage/config/general.yml @@ -3,6 +3,7 @@ name: My fantastic App email: andresmontanez@gmail.com notifications: true logging: true +verbose_logging: false scm: type: git url: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git