简体   繁体   English

如何在日志下方打印django-nose异常

[英]How to print django-nose exception below log

Django-nose prints the exception and stack trace somewhere hidden in the middle of two logs in the following format: Django-nose以以下格式将异常和堆栈跟踪打印在两个日志中间隐藏的位置:

  1. Live Log (as it is being executed) 实时日志(正在执行)
  2. The exception and stack trace 异常和堆栈跟踪
  3. The recorded log 记录的日志

This is really unhelpful if the logs are very long (hundreds of lines) as one has to find the "in between" stack trace to know what actually went wrong, rather than just scrolling to the bottom and being able to see the error. 如果日志很长(几百行),这真的无济于事,因为必须找到“中间”堆栈跟踪以了解实际出了什么问题,而不是仅仅滚动到底部并能够看到错误。

Is there any way of formatting this differently so that the stack trace and exception are printed last (aka 1. Live log, 2. recorded log, 3. exception and stack trace)?! 有什么方法可以格式化此格式,以便最后显示堆栈跟踪和异常(aka 1.实时日志,2。记录的日志,3。异常和堆栈跟踪)? From what I can tell there are no options to do so. 据我所知,没有其他选择。

Nose keeps track of standard output (stdout) and logging (python logging module) in separate containers. 鼻子在单独的容器中跟踪标准输出(stdout)和日志记录(python日志记录模块)。 You can control the capturing process of the output during the test run for both buffers. 您可以在测试运行期间控制两个缓冲区的输出捕获过程。 So if you want to disable capturing of the recorded log with --nocapture and --nologcapture your tests will end with stack trace. 因此,如果您想使用--nocapture--nologcapture禁用捕获记录的日志, --nocapture测试将以堆栈跟踪结束。 This way step (3) will be eliminated. 这样,步骤(3)将被消除。 To reorder sequence as you describe it, you may want to make a custom plugin. 要按照描述的顺序重新排序,您可能需要制作一个自定义插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM