Class: SeaShanty::Logger

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

Defined Under Namespace

Classes: NullLogger

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(destination) ⇒ Logger



7
8
9
10
11
12
13
# File 'lib/sea_shanty/util/logger.rb', line 7

def initialize(destination)
  @destination = if destination.respond_to? :printf
    destination
  else
    File.open(destination.to_s, "a+")
  end
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



5
6
7
# File 'lib/sea_shanty/util/logger.rb', line 5

def destination
  @destination
end

Instance Method Details

#log(message) ⇒ Object



15
16
17
18
# File 'lib/sea_shanty/util/logger.rb', line 15

def log(message)
  destination.write(message)
  destination.write("\n") unless message.end_with?("\n")
end