Class: Websitary::AppLog

Inherits:
Object
  • Object
show all
Defined in:
lib/websitary/applog.rb

Overview

A simple wrapper around Logger.

Instance Method Summary collapse

Constructor Details

#initialize(output = nil) ⇒ AppLog

Returns a new instance of AppLog.



12
13
14
15
16
17
18
# File 'lib/websitary/applog.rb', line 12

def initialize(output=nil)
    @output = output || $stdout
    $logger = Logger.new(@output, 'daily')
    $logger.progname = Websitary::APPNAME
    $logger.datetime_format = "%H:%M:%S"
    set_level
end

Instance Method Details

#set_level(level = :default) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/websitary/applog.rb', line 21

def set_level(level=:default)
    case level
    when :debug
        $logger.level = Logger::DEBUG
    when :verbose
        $logger.level = Logger::INFO
    when :quiet
        $logger.level = Logger::ERROR
    else
        $logger.level = Logger::WARN
    end
    $logger.debug "Set logger level: #{level}"
end