You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2017/04/24 10:55:29 UTC
[8/9] incubator-ariatosca git commit: added markingup
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/ceb88db8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ceb88db8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ceb88db8
Branch: refs/heads/ARIA-146-Support-colorful-execution-logging
Commit: ceb88db8315031df487af0bab599d29624ab01f9
Parents: 86cb111
Author: max-orlov <ma...@gigaspaces.com>
Authored: Fri Apr 21 19:04:09 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Mon Apr 24 11:47:11 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/ceb88db8/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/ceb88db8/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: