From 575632d62bd97a5653a299a38e17991fe937c7ab Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Fri, 31 Oct 2014 20:06:54 +0100 Subject: [PATCH 1/6] Enable configurable verbose logging --- Mage/Console.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mage/Console.php b/Mage/Console.php index b9dd97c..541ed4a 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -227,6 +227,10 @@ class Console $message = date('Y-m-d H:i:s -- ') . $message; fwrite(self::$log, $message . PHP_EOL); + + if (self::$config->general('verbose_logging', false)) { + echo $message . PHP_EOL; + } } } From 67e00bca59ea8776bfacbb514fd53037d2678711 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:27:33 +0100 Subject: [PATCH 2/6] Add verbose logging state variable --- Mage/Console.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Mage/Console.php b/Mage/Console.php index 541ed4a..a0819af 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 = $config->general('verbose_logging', false); + // Greetings if ($showGreetings) { if (!self::$logEnabled) { @@ -228,7 +236,7 @@ class Console $message = date('Y-m-d H:i:s -- ') . $message; fwrite(self::$log, $message . PHP_EOL); - if (self::$config->general('verbose_logging', false)) { + if (self::$verboseLogEnabled) { echo $message . PHP_EOL; } } From 654753b70fa4d3d7fa07869ff1b13830f3451a8f Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:29:46 +0100 Subject: [PATCH 3/6] Avoid duplicating output when verbose option is turned on --- Mage/Console.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Mage/Console.php b/Mage/Console.php index a0819af..43f7e36 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -181,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; + } } /** From 0734c7be0a0b8ff0263ead3532ff06a9d085d541 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:34:50 +0100 Subject: [PATCH 4/6] Check if verbose logging is enabled --- Mage/Console.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Mage/Console.php b/Mage/Console.php index 43f7e36..db378a1 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -113,7 +113,7 @@ class Console self::$logEnabled = $config->general('logging', false); } - self::$verboseLogEnabled = $config->general('verbose_logging', false); + self::$verboseLogEnabled = self::isVerboseLoggingEnabled(); // Greetings if ($showGreetings) { @@ -300,4 +300,13 @@ 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'); + } + } From d63d10547128485a10edef603dc80724680f682b Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:38:26 +0100 Subject: [PATCH 5/6] Add ability to set 'verbose_logging' for environment --- Mage/Console.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mage/Console.php b/Mage/Console.php index db378a1..8dd7940 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -306,7 +306,9 @@ class Console */ protected static function isVerboseLoggingEnabled() { - return self::$config->getParameter('verbose', false) || self::$config->general('verbose_logging'); + return self::$config->getParameter('verbose', false) + || self::$config->general('verbose_logging') + || self::$config->environmentConfig('verbose_logging', false); } } From 9eb61d1d4badf9a3b60b787b7ea8a430eb6e633d Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:40:58 +0100 Subject: [PATCH 6/6] Write down some example of verbose usage option --- docs/commands.txt | 4 +++- docs/example-config/.mage/config/environment/production.yml | 1 + docs/example-config/.mage/config/environment/staging.yml | 1 + docs/example-config/.mage/config/general.yml | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) 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