本文整理汇总了Python中citest.base.JournalLogger.debug方法的典型用法代码示例。如果您正苦于以下问题:Python JournalLogger.debug方法的具体用法?Python JournalLogger.debug怎么用?Python JournalLogger.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类citest.base.JournalLogger
的用法示例。
在下文中一共展示了JournalLogger.debug方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_journal_logger_with_custom_message
# 需要导入模块: from citest.base import JournalLogger [as 别名]
# 或者: from citest.base.JournalLogger import debug [as 别名]
def test_journal_logger_with_custom_message(self):
offset = len(_journal_file.getvalue())
logger = JournalLogger(__name__)
logger.addHandler(JournalLogHandler(path=None))
citest_extra = {'foo':'bar', '_journal_message':'HELLO, JOURNAL'}
logger.debug('Hello, World!', extra={'citest_journal': citest_extra})
expect = {
'_value': 'HELLO, JOURNAL',
'_type': 'JournalMessage',
'_level': logging.DEBUG,
'_timestamp': _journal_clock.last_time,
'_thread': current_thread().ident,
'foo': 'bar',
'format': 'pre'
}
entry_str = _journal_file.getvalue()[offset:]
json_str = next(RecordInputStream(BytesIO(entry_str)))
json_dict = json_module.JSONDecoder().decode(json_str)
self.assertEqual(expect, json_dict)
示例2: test_context_logging
# 需要导入模块: from citest.base import JournalLogger [as 别名]
# 或者: from citest.base.JournalLogger import debug [as 别名]
def test_context_logging(self):
offset = len(_journal_file.getvalue())
logger = JournalLogger('test_journal_logger')
logger.addHandler(JournalLogHandler(path=None))
citest_extra = {'foo':'bar'}
start_time = _journal_clock.last_time
JournalLogger.execute_in_context(
'The Test Context',
lambda: {logger.debug('Test Log Message')},
**citest_extra)
expect_sequence = [
{
'_title': 'The Test Context',
'_type': 'JournalContextControl',
'_timestamp': start_time + 1,
'_thread': current_thread().ident,
'control': 'BEGIN',
'foo': 'bar',
},
{
'_value': 'Test Log Message',
'_type': 'JournalMessage',
'_level': logging.DEBUG,
'_timestamp': start_time + 2,
'_thread': current_thread().ident,
'format': 'pre'
},
{
'_type': 'JournalContextControl',
'_timestamp': start_time + 3,
'_thread': current_thread().ident,
'control': 'END'
}
]
entry_str = _journal_file.getvalue()[offset:]
input_stream = RecordInputStream(BytesIO(entry_str))
for expect in expect_sequence:
json_str = next(input_stream)
json_dict = json_module.JSONDecoder().decode(json_str)
self.assertEqual(expect, json_dict)