Skip to content

Commit

Permalink
initial support for information dump
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 8, 2015
1 parent 29515f2 commit 80b7668
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/netius/base/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,9 @@ def info_dict(self, full = False):
)
return info

def info_string(self, full = False):
info = self.info_dict(full = full)
def info_string(self, full = False, safe = True):
try: info = self.info_dict(full = full)
except: info = dict()
info_s = json.dumps(
info,
ensure_ascii = False,
Expand Down Expand Up @@ -863,10 +864,16 @@ def error(self, object):
def critical(self, object):
self.log(object, level = logging.CRITICAL)

def log_stack(self, method = None):
def log_stack(self, method = None, info = True):
if not method: method = self.info
lines = traceback.format_exc().splitlines()
for line in lines: method(line)
if info: self.log_info(method = method)

def log_info(self, method = None):
if not method: method = self.info
info_string = self.info_string(full = True)
for line in info_string.split("\n"): method(line)

def log(self, *args, **kwargs):
if legacy.PYTHON_3: return self.log_python_3(*args, **kwargs)
Expand Down

0 comments on commit 80b7668

Please sign in to comment.