Class: InternetHakai::Logger

Inherits:
BaseHandler show all
Defined in:
lib/internethakai/logger.rb

Overview

ロガー

Constant Summary collapse

UNIQUE_BY_THREAD =
false

Instance Method Summary collapse

Methods inherited from BaseHandler

clear, clearall, get_class, get_config, get_handler, get_instance, get_instance_thread, get_thread_id, #initialize, #on_create, set_config, set_thread_id, unique_by_thread?

Constructor Details

This class inherits a constructor from InternetHakai::BaseHandler

Instance Method Details

#crit(text) ⇒ Object



35
36
37
38
# File 'lib/internethakai/logger.rb', line 35

def crit text
    print text
    STDOUT.flush
end

#debug(text) ⇒ Object



43
44
45
46
# File 'lib/internethakai/logger.rb', line 43

def debug text
    print Util::recover_encoding(text, @config)
    STDOUT.flush
end

#debugverbose(text) ⇒ Object



47
48
49
50
# File 'lib/internethakai/logger.rb', line 47

def debugverbose text
    print Util::recover_encoding(text, @config)
    STDOUT.flush
end

#emerg(text) ⇒ Object



39
40
41
42
# File 'lib/internethakai/logger.rb', line 39

def emerg text
    print text
    STDOUT.flush
end

#init(config) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/internethakai/logger.rb', line 5

def init(config)
    @config = config
    level = @config['log_level']
    if level <= 3
        def debugverbose text
        end
    end
    if level <= 2
        def debug text
        end
    end
    if level == 1
        def emerg text
        end
    end
    @level = level
end

#run(text, level = 3) ⇒ Object

出力ログレベルより小さいレベルの場合に出力



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/internethakai/logger.rb', line 23

def run text, level = 3
    case level
        when 4
        debugverbose text
        when 3
        debug text
        when 2
        emerg text
        when 1
        crit text
    end
end