From: Matthew Smillie Date: 2006-06-08T07:26:48+09:00 Subject: Re: output delay On Jun 7, 2006, at 22:06, Daniel Shackelford wrote: > Howdy, > > I am doing some log processing (cross referencing multiple logs, > and activating triggers based on the results) and printing the > results to stdout for testing while writing to a file at the same > time. The symptom that I am seeing is that the output to stdout is > immediate, while tailing the file with the same output seems to be > one entry behind. Here is what the code looks like: This is the result of buffered output, one simple change ought to fix it up: > > logRoot = '/var/log/' > blockLog = File.open(logRoot + 'block.log', "a+") > result = searchFW(src,dst,path,time) # does a > search for the needed info in the log, and returns the matching lines > unless result.empty? > token = parseFW(result) # > runs the results through a parser that pulls out the relevant bits > blockLog << date+"+"+token+"+"+url+"\n" blockLog.flush > p date+"+"+token+"+"+url > end