You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/02/26 02:27:44 UTC

[incubator-openwhisk] branch master updated: Extract message from callback and add it to pretty printed text. (#3344)

This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new fddc083  Extract message from callback and add it to pretty printed text. (#3344)
fddc083 is described below

commit fddc083011c99bec315a9506cf073e70cb0c1c93
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Sun Feb 25 21:27:42 2018 -0500

    Extract message from callback and add it to pretty printed text. (#3344)
---
 ansible/callbacks/logformatter.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/ansible/callbacks/logformatter.py b/ansible/callbacks/logformatter.py
index 754b68e..c2aabb2 100644
--- a/ansible/callbacks/logformatter.py
+++ b/ansible/callbacks/logformatter.py
@@ -20,6 +20,7 @@
 from __future__ import (absolute_import, division, print_function)
 import os
 import sys
+import textwrap
 from ansible.plugins.callback import CallbackBase
 __metaclass__ = type
 
@@ -35,14 +36,18 @@ class CallbackModule(CallbackBase):
         """Emit colorized output based upon data contents."""
         if type(data) == dict:
             cmd = data['cmd'] if 'cmd' in data else None
+            msg = data['msg'] if 'msg' in data else None
             stdout = data['stdout'] if 'stdout' in data else None
             stderr = data['stderr'] if 'stderr' in data else None
             reason = data['reason'] if 'reason' in data else None
 
+            print()
             if cmd:
-                print(hilite('[%s]\n> %s' % (category, cmd), category))
+                print(hilite('[%s]\n> %s' % (category, cmd), category, wrap = False))
             if reason:
                 print(hilite(reason, category))
+            if msg:
+                print(hilite(msg, category))
             if stdout:
                 print(hilite(stdout, category))
             if stderr:
@@ -64,7 +69,7 @@ class CallbackModule(CallbackBase):
         self.emit(host, 'FAILED', res)
 
 
-def hilite(msg, status):
+def hilite(msg, status, wrap = True):
     """Highlight message."""
     def supports_color():
         if ((sys.platform != 'win32' or 'ANSICON' in os.environ) and
@@ -81,6 +86,7 @@ def hilite(msg, status):
         else:
             # bold
             attr.append('1')
-        return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), msg)
+        text = '\x1b[%sm%s\x1b[0m' % (';'.join(attr), msg)
     else:
-        return msg
+        text = msg
+    return textwrap.fill(text, 80) if wrap else text

-- 
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.