我正在运行一个烧瓶应用程序,并试图刷新到一个进程的标准输出到一个日志文件的实时。当我以开发模式(ENV FLASK_ENV=development)运行我的坞化应用程序时,它工作得很好。我的stdout被冲到日志文件上,我写得太快了,而且效果很好。
with open("./logs/log.txt", "wb") as f:
with stdio_proxy.redirect_stdout(f):
print("code whose stdout I want in the logs goes here"
我正在尝试阅读CI 2的源代码,我对此感到困惑,在/Loader类的视图方法中。
/*
* Flush the buffer... or buff the flusher?
*
* In order to permit views to be nested within
* other views, we need to flush the content back out whenever
* we are beyond the first level of output buffering so that
* it
我想知道我应该写多长时间才能超过缓冲区,从而自动刷新缓冲区本身。
try
{
BufferedWriter br = new BufferedWriter(new FileWriter(file),1);
br.write("How much should I write in order to get it flushed without using .flush() nor close());
我知道close()会自动刷新缓冲区,但我也知道,一旦缓冲区满了并且收到了更多的输入,它就会刷新它,然后得到更多的输入。那么,为了克服构造函