Class: Lumberjack::Device::LogFile

Inherits:
Writer show all
Defined in:
lib/lumberjack/device/log_file.rb

Overview

This is a logging device that appends log entries to a file.

Direct Known Subclasses

RollingLogFile

Constant Summary

Constants inherited from Writer

Writer::DEFAULT_ADDITIONAL_LINES_TEMPLATE, Writer::DEFAULT_FIRST_LINE_TEMPLATE

Instance Attribute Summary collapse

Attributes inherited from Writer

#buffer_size

Instance Method Summary collapse

Methods inherited from Writer

#close, #flush, #write

Methods inherited from Lumberjack::Device

#cleanup_files!, #close, #do_once, #flush, #write

Constructor Details

#initialize(path, options = {}) ⇒ LogFile

Create a logger to the file at path. Options are passed through to the Writer constructor.



11
12
13
14
15
# File 'lib/lumberjack/device/log_file.rb', line 11

def initialize(path, options = {})
  @path = File.expand_path(path)
  FileUtils.mkdir_p(File.dirname(@path))
  super(File.new(@path, 'a', :encoding => "ascii-8bit"), options)
end

Instance Attribute Details

#pathObject (readonly)

The absolute path of the file being logged to.



8
9
10
# File 'lib/lumberjack/device/log_file.rb', line 8

def path
  @path
end