Skip to content

Commit

Permalink
Merge pull request #3 from skwerlman/patch-1
Browse files Browse the repository at this point in the history
Improve formatting of multi-line messages
  • Loading branch information
rlafuente committed Jan 28, 2016
2 parents e170087 + f6d4234 commit 0825944
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions zenlog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,34 @@ def __init__(self, lvl=logging.DEBUG, format=None):
# to inject new items into the logging.LogRecord objects
# we also create our convenience methods here
def critical(self, message, *args, **kwargs):
self.logger.critical(message,
extra={"styledname": self.theme[logging.CRITICAL]},
*args, **kwargs)
for line in str(message).splitlines():
self.logger.critical(line,
extra={"styledname": self.theme[logging.CRITICAL]},
*args, **kwargs)
crit = c = fatal = critical
def error(self, message, *args, **kwargs):
self.logger.error(message,
extra={"styledname": self.theme[logging.ERROR]},
*args, **kwargs)
for line in str(message).splitlines():
self.logger.error(line,
extra={"styledname": self.theme[logging.ERROR]},
*args, **kwargs)
err = e = error
def warn(self, message, *args, **kwargs):
self.logger.warn(message,
extra={"styledname": self.theme[logging.WARNING]},
*args, **kwargs)
for line in str(message).splitlines():
self.logger.warn(line,
extra={"styledname": self.theme[logging.WARNING]},
*args, **kwargs)
warning = w = warn
def info(self, message, *args, **kwargs):
self.logger.info(message,
extra={"styledname": self.theme[logging.INFO]},
*args, **kwargs)
for line in str(message).splitlines():
self.logger.info(line,
extra={"styledname": self.theme[logging.INFO]},
*args, **kwargs)
inf = nfo = i = info
def debug(self, message, *args, **kwargs):
self.logger.debug(message,
extra={"styledname": self.theme[logging.DEBUG]},
*args, **kwargs)
for line in str(message).splitlines():
self.logger.debug(line,
extra={"styledname": self.theme[logging.DEBUG]},
*args, **kwargs)
dbg = d = debug

# other convenience functions to set the global logging level
Expand Down

0 comments on commit 0825944

Please sign in to comment.