Class: Moneta::Logger::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/moneta/logger.rb

Overview

Standard formatter used by the logger

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Format

Returns a new instance of Format.



8
9
10
11
12
13
14
15
16
17
# File 'lib/moneta/logger.rb', line 8

def initialize(options)
  @prefix = options[:prefix] || 'Moneta '
  if options[:file]
    @close = true
    @out = File.open(options[:file], 'a')
  else
    @close = options[:close]
    @out = options[:out] || STDOUT
  end
end

Instance Method Details

#closeObject



23
24
25
# File 'lib/moneta/logger.rb', line 23

def close
  @out.close if @close
end

#log(entry) ⇒ Object



19
20
21
# File 'lib/moneta/logger.rb', line 19

def log(entry)
  @out.write(format(entry))
end