Python记录器快速打印出意外

时间:2019-11-27 16:47:24

标签: python logging

我注意到一些有趣/有趣的事情,那就是在使用记录仪时,它“打印得太快了”。

我要连续对12个检查的数据集重复相同的操作,因此记录仪应该打印出我正在处理的数据集,然后仅使用print()来读取详细信息。

它的布局是这样的:

INFO:__main__:Results for Science I #logger text
Overall Test: True


Quick Head Test
Correct Test Cases:
[redacted]
Output:
[redacted]


Quick Tail Test
Correct Test Cases:
[redacted]
Output:
[redacted]


Quick Cell to Cell Differences
Empty DataFrame
Columns: [Test, Output]
Index: []

但是后来我注意到了这个短消息:

Quick Cell to Cell Differences
INFO:__main__:Results for Science II #logger text
Empty DataFrame
Columns: [Test, Output]
Index: []

从技术上讲,我们仍处于另一门考试的中间状态,因此《科学II》在“开始”了。

这不是问题,只是我注意到的一些有趣的事情。顺便说一句,代码如下:

##### After changing code:
# test against the previous correct outputs

def dev_test(exam):
    main.main(exam,
              dev_test_deployment=True)

# Use dev_test() at first to look at one dataframe.
# dev_test('History')

# You can change the verbose flag to True if there are discreprancies you can't account for
# and need to do additional digging.

def all_dev_test():
    # We use logging as the text shows up as red, to differentiate each exam (as a header) before the nitty gritty of
    # how the new code performs.
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger(__name__)

    for exam in oa.regents_june_2019_exams:
        logger.info(f'Results for {exam}')
        dev_test(exam)

all_dev_test()

[提取相关代码并清理掉与我的组织相关的任何东西都需要很长时间,这就是为什么我现在不能提供良好的MVE。]

0 个答案:

没有答案