本文整理汇总了Python中coalib.output.printers.LogPrinter.LogPrinter.debug方法的典型用法代码示例。如果您正苦于以下问题:Python LogPrinter.debug方法的具体用法?Python LogPrinter.debug怎么用?Python LogPrinter.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coalib.output.printers.LogPrinter.LogPrinter
的用法示例。
在下文中一共展示了LogPrinter.debug方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_logging
# 需要导入模块: from coalib.output.printers.LogPrinter import LogPrinter [as 别名]
# 或者: from coalib.output.printers.LogPrinter.LogPrinter import debug [as 别名]
def test_logging(self):
uut = LogPrinter(timestamp_format="")
uut.logger = mock.MagicMock()
uut.log_message(self.log_message)
msg = Constants.COMPLEX_TEST_STRING
uut.logger.log.assert_called_with(logging.ERROR, msg)
uut = LogPrinter(log_level=LOG_LEVEL.DEBUG)
uut.logger = mock.MagicMock()
uut.log(LOG_LEVEL.ERROR, Constants.COMPLEX_TEST_STRING)
uut.logger.log.assert_called_with(logging.ERROR, msg)
uut.debug(Constants.COMPLEX_TEST_STRING, "d")
uut.logger.log.assert_called_with(logging.DEBUG, msg + " d")
uut.log_level = LOG_LEVEL.DEBUG
uut.log_exception("Something failed.", NotImplementedError(msg))
uut.logger.log.assert_any_call(logging.ERROR, "Something failed.")
uut.logger.log.assert_called_with(
logging.INFO,
"Exception was:\n{exception}: {msg}".format(
exception="NotImplementedError",
msg=msg))
示例2: test_logging
# 需要导入模块: from coalib.output.printers.LogPrinter import LogPrinter [as 别名]
# 或者: from coalib.output.printers.LogPrinter.LogPrinter import debug [as 别名]
def test_logging(self):
uut = LogPrinter(StringPrinter(), timestamp_format="")
uut.log_message(self.log_message, end="")
self.assertEqual(uut.printer.string, str(self.log_message))
uut = LogPrinter(StringPrinter(), log_level=LOG_LEVEL.DEBUG)
uut.log_message(self.log_message, end="")
self.assertEqual(
uut.printer.string,
"[ERROR][" + self.timestamp.strftime("%X") + "] " +
Constants.COMPLEX_TEST_STRING)
uut.printer.clear()
uut.log(LOG_LEVEL.ERROR,
Constants.COMPLEX_TEST_STRING,
timestamp=self.timestamp,
end="")
self.assertEqual(
uut.printer.string,
"[ERROR][" + self.timestamp.strftime("%X") + "] " +
Constants.COMPLEX_TEST_STRING)
uut.printer.clear()
uut.debug(Constants.COMPLEX_TEST_STRING,
"d",
timestamp=self.timestamp,
end="")
self.assertEqual(
uut.printer.string,
"[DEBUG][" + self.timestamp.strftime("%X") + "] " +
Constants.COMPLEX_TEST_STRING + " d")
uut.printer.clear()
uut.log_level = LOG_LEVEL.INFO
uut.debug(Constants.COMPLEX_TEST_STRING,
timestamp=self.timestamp,
end="")
self.assertEqual(uut.printer.string, "")
uut.printer.clear()
uut.info(Constants.COMPLEX_TEST_STRING,
"d",
timestamp=self.timestamp,
end="")
self.assertEqual(
uut.printer.string,
"[INFO][" + self.timestamp.strftime("%X") + "] " +
Constants.COMPLEX_TEST_STRING + " d")
uut.log_level = LOG_LEVEL.WARNING
uut.printer.clear()
uut.debug(Constants.COMPLEX_TEST_STRING,
timestamp=self.timestamp,
end="")
self.assertEqual(uut.printer.string, "")
uut.printer.clear()
uut.warn(Constants.COMPLEX_TEST_STRING,
"d",
timestamp=self.timestamp,
end="")
self.assertEqual(
uut.printer.string,
"[WARNING][" + self.timestamp.strftime("%X") + "] " +
Constants.COMPLEX_TEST_STRING + " d")
uut.printer.clear()
uut.err(Constants.COMPLEX_TEST_STRING,
"d",
timestamp=self.timestamp,
end="")
self.assertEqual(
uut.printer.string,
"[ERROR][" + self.timestamp.strftime("%X") + "] " +
Constants.COMPLEX_TEST_STRING + " d")
uut.log_level = LOG_LEVEL.DEBUG
uut.printer.clear()
uut.log_exception(
"Something failed.",
NotImplementedError(Constants.COMPLEX_TEST_STRING),
timestamp=self.timestamp)
self.assertTrue(uut.printer.string.startswith(
"[ERROR][" + self.timestamp.strftime("%X") +
"] Something failed.\n" +
"[DEBUG][" + self.timestamp.strftime("%X") +
"] Exception was:"))
uut.log_level = LOG_LEVEL.INFO
uut.printer.clear()
logged = uut.log_exception(
"Something failed.",
NotImplementedError(Constants.COMPLEX_TEST_STRING),
timestamp=self.timestamp,
end="")
self.assertTrue(uut.printer.string.startswith(
"[ERROR][" + self.timestamp.strftime("%X") +
"] Something failed."))