Skip to content

Commit

Permalink
out_stdout uses logger instead of STDOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
frsyuki committed Apr 30, 2012
1 parent 9725ad1 commit dcdf407
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/fluent/log.rb
Expand Up @@ -227,6 +227,14 @@ def puts(msg)
nil
end

def write(data)
@out.write(data)
end

def flush
@out.flush
end

private
def event(level, args)
time = Time.now
Expand Down
6 changes: 2 additions & 4 deletions lib/fluent/plugin/out_stdout.rb
Expand Up @@ -21,13 +21,11 @@ module Fluent
class StdoutOutput < Output
Plugin.register_output('stdout', self)

config_param :autoflush, :bool, :default => false

def emit(tag, es, chain)
es.each {|time,record|
puts "#{Time.at(time).localtime} #{tag}: #{Yajl.dump(record)}"
$log.write "#{Time.at(time).localtime} #{tag}: #{Yajl.dump(record)}\n"
}
STDOUT.flush if @autoflush
$log.flush

chain.next
end
Expand Down

0 comments on commit dcdf407

Please sign in to comment.