From 5cb7f8af710627b90bb38f9b5ece5c0ebc3bdfde Mon Sep 17 00:00:00 2001 From: evasquez Date: Tue, 17 Dec 2013 15:59:37 -0600 Subject: AIT-622: Add pretty print formatting to loggers. Signed-off-by: evasquez --- cxmanage_api/loggers.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cxmanage_api/loggers.py b/cxmanage_api/loggers.py index 26edf21..777faed 100644 --- a/cxmanage_api/loggers.py +++ b/cxmanage_api/loggers.py @@ -39,6 +39,7 @@ target. import os +import pprint import datetime import traceback @@ -100,7 +101,14 @@ class Logger(object): :type level_tag: string """ - lines = msg.split('\n') + lines = pprint.pformat(msg).splitlines() + if len(lines) == 1: + # + # We don't care about single line formatting. + # Make sure we get __str__ instead of __repr___ + # + lines = str(msg).splitlines() + result = [] for line in lines: if (self.time_stamp): -- cgit v1.2.1