class Bauxite::Loggers::FileLogger

File logger.

This logger outputs the raw action text for every action executed to the file specified in the file logger option.

File logger options include:

file

Output file name.

verbose

Output all log (e.g. errors) to the file.

Public Class Methods

new(options) click to toggle source

Constructs a new echo logger instance.

Calls superclass method Bauxite::Loggers::NullLogger.new
# File lib/bauxite/loggers/file.rb, line 36
def initialize(options)
        super(options)
        @file = options[:file]
        unless @file and @file != ''
                raise ArgumentError, "FileLogger configuration error: Undefined 'file' option."
        end
        @verbose = options[:verbose]
        @lines = []
end

Public Instance Methods

finalize(ctx) click to toggle source

Completes the log execution.

# File lib/bauxite/loggers/file.rb, line 47
def finalize(ctx)
        File.open(ctx.output_path(@file), 'w') { |f| f.write(@lines.join("\n")) }
end
log(s, type = :info) click to toggle source

Logs the specified string.

type, if specified, should be one of :error, :warning, :info (default), :debug.

Calls superclass method Bauxite::Loggers::NullLogger#log
# File lib/bauxite/loggers/file.rb, line 62
def log(s, type = :info)
        if @verbose
                @lines << s
        else
                super
        end
end
log_cmd(action) { || ... } click to toggle source

Echoes the raw action text.

# File lib/bauxite/loggers/file.rb, line 52
def log_cmd(action)
        @lines << action.text
        yield
end