Class: Loggability::LogDevice::File

Inherits:
Loggability::LogDevice show all
Defined in:
lib/loggability/log_device/file.rb

Overview

A log device that delegates to the ruby’s default Logger’s file device and writes to a file descriptor or a file.

Constant Summary

Constants inherited from Loggability::LogDevice

DEVICE_TARGET_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Loggability::LogDevice

create, load_device_type, parse_device_spec

Constructor Details

#initialize(target) ⇒ File

Create a new File device that will write to the file using the built-in ruby’s File log device



13
14
15
# File 'lib/loggability/log_device/file.rb', line 13

def initialize( target )
	@target = ::Logger::LogDevice.new( target )
end

Instance Attribute Details

#targetObject (readonly)

The target of the log device



23
24
25
# File 'lib/loggability/log_device/file.rb', line 23

def target
  @target
end

Instance Method Details

#closeObject

close the file



33
34
35
# File 'lib/loggability/log_device/file.rb', line 33

def close
	self.target.close
end

#write(message) ⇒ Object

Append the specified message to the target.



27
28
29
# File 'lib/loggability/log_device/file.rb', line 27

def write( message )
	self.target.write( message )
end