Class: WT::Log

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

Constant Summary collapse

LOG_ERROR =
0
LOG_WARN =
1
LOG_INFO =
2
LOG_DEBUG =
3
@@enabled =
false
@@output =
nil
@@level =
LOG_ERROR

Class Method Summary collapse

Class Method Details

.debug(text, *args) ⇒ Object



22
23
24
# File 'lib/log.rb', line 22

def self.debug(text, *args)
    self.log(LOG_DEBUG, text, *args)
end

.enable=(value) ⇒ Object



38
39
40
# File 'lib/log.rb', line 38

def self.enable=(value)
    @@enabled = value
end

.enabledObject



42
43
44
# File 'lib/log.rb', line 42

def self.enabled
    @@enabled
end

.error(text, *args) ⇒ Object



34
35
36
# File 'lib/log.rb', line 34

def self.error(text, *args)
    self.log(LOG_ERROR, text, *args)
end

.info(text, *args) ⇒ Object



26
27
28
# File 'lib/log.rb', line 26

def self.info(text, *args)
    self.log(LOG_INFO, text, *args)
end

.initializeObject



15
16
17
18
19
20
# File 'lib/log.rb', line 15

def self.initialize
    unless @@initialized
        STDOUT.reopen(File.open(WT.log_output, 'a')) if @@output
        @@initialized = true
    end
end

.levelObject



50
51
52
# File 'lib/log.rb', line 50

def self.level
    @@level
end

.level=(lvl) ⇒ Object



46
47
48
# File 'lib/log.rb', line 46

def self.level=(lvl)
    @@level = lvl
end

.outputObject



58
59
60
# File 'lib/log.rb', line 58

def self.output
    @@output
end

.output=(output) ⇒ Object



54
55
56
# File 'lib/log.rb', line 54

def self.output=(output)
    @@output = output
end

.warn(text, *args) ⇒ Object



30
31
32
# File 'lib/log.rb', line 30

def self.warn(text, *args)
    self.log(LOG_WARN, text, *args)
end