def obj(self, cfg, title, obj, depth=1): '''Log the object with a title, pretty printed. Args: cfg (DotMap): The configuration. title (string): The title to log. obj (dict): The object to log. depth (type): To what depth to object should be expanded. Returns: type: Description of returned object. Raises: ExceptionName: Why the exception is raised. ''' opts = cfg.options pretty_print = pprint.PrettyPrinter(indent=2, depth=depth) msg = Text.replace(pretty_print.pformat(obj), [('u?\'', '\''), ('^{', '{' + opts.newline + ' '), ('}$', opts.newline + '}')]) self.log(cfg, title, msg)
def log(self, cfg, *args): '''Log the parameters. Args: cfg (DotMap): The configuration. *args (list): Parameters to be logged. ''' opts = cfg.options message = opts.newline + opts.newline.join(args) print(message) # Don't log if the log level for this call is lower than the configured log level. if self.log_level < opts.log_level: return logfile_message = Text.replace(message, [('^' + opts.newline, ''), (opts.newline, opts.newline + ' ')]) self.logger.log(self.log_level, logfile_message)