提交 6703f909 编写于 作者: J Jeremy Kemper

Cheaper log tail time comparison

上级 a9fde9a2
......@@ -7,16 +7,16 @@ def initialize(app, log = nil)
@app = app
@path = Pathname.new(log || EnvironmentLog).cleanpath
@cursor = ::File.size(@path)
@last_checked = Time.now
@last_checked = Time.now.to_f
end
def call(env)
response = @app.call(env)
::File.open(@path, 'r') do |f|
f.seek @cursor
if f.mtime > @last_checked
if f.mtime.to_f > @last_checked
contents = f.read
@last_checked = f.mtime
@last_checked = f.mtime.to_f
@cursor += contents.length
print contents
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册