Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-146-Support-colorful-execution-logging 909ccaace -> 1fc9ac756


added markingup


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/dbcef5fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/dbcef5fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/dbcef5fd

Branch: refs/heads/ARIA-146-Support-colorful-execution-logging
Commit: dbcef5fdd2eca1c8dd4c7473846b401fa677d8fa
Parents: 909ccaa
Author: max-orlov <[email protected]>
Authored: Fri Apr 21 19:04:09 2017 +0300
Committer: max-orlov <[email protected]>
Committed: Fri Apr 21 19:04:09 2017 +0300

----------------------------------------------------------------------
 aria/cli/color.py             | 13 ++++++++++---
 aria/cli/execution_logging.py | 11 ++++++++++-
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/dbcef5fd/aria/cli/color.py
----------------------------------------------------------------------
diff --git a/aria/cli/color.py b/aria/cli/color.py
index ed71238..a5ed9b7 100644
--- a/aria/cli/color.py
+++ b/aria/cli/color.py
@@ -39,12 +39,19 @@ class StyledString(object):
     def __str__(self):
         return self._stylized_str
 
+    def _style_str(self, styling_str=None):
+        str_ = styling_str or StringIO
+        for arg in self._args:
+            str_.write(arg)
+        if styling_str is not None:
+            return str_
+        else:
+            return str_.getvalue()
+
     def _apply_style(self):
         assert all(self._is_valid(arg) for arg in self._args)
-
         styling_str = StringIO()
-        for arg in self._args:
-            styling_str.write(arg)
+        self._style_str(styling_str)
         styling_str.write(self._original_str)
         styling_str.write(self.STYLE.RESET_ALL)
         self._stylized_str = styling_str.getvalue()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/dbcef5fd/aria/cli/execution_logging.py
----------------------------------------------------------------------
diff --git a/aria/cli/execution_logging.py b/aria/cli/execution_logging.py
index 6019b94..f8eec22 100644
--- a/aria/cli/execution_logging.py
+++ b/aria/cli/execution_logging.py
@@ -100,6 +100,13 @@ class _StylizedLogs(object):
     def _style(self, msg, level, style_type):
         return StyledString(msg, *self._styles[style_type].get(level.lower(), 
[]))
 
+    def back(self, str_):
+        if 'web_app' not in str_:
+            return str_
+        modified_str = StyledString.BACK.LIGHTYELLOW_EX +\
+                       str_.replace(StyledString.STYLE.RESET_ALL,
+                                    StyledString.STYLE.RESET_ALL + 
StyledString.BACK.LIGHTYELLOW_EX) + StyledString.STYLE.RESET_ALL
+        return modified_str
 
 stylized_log = _StylizedLogs()
 
@@ -138,7 +145,9 @@ def _str(item, formats=None):
     # message
     formatting_kwargs['message'] = stylized_log.message(item.msg, item.level)
 
-    msg.write(formatting['message'].format(**formatting_kwargs))
+    message = formatting['message'].format(**formatting_kwargs)
+    message = stylized_log.back(message)
+    msg.write(message)
 
     # Add the exception and the error msg.
     if item.traceback and env.logging.verbosity_level >= logger.MEDIUM_VERBOSE:

Reply via email to