Class: XscreenUsbUnlocker::Logger
- Inherits:
-
Object
- Object
- XscreenUsbUnlocker::Logger
show all
- Defined in:
- lib/xscreen_usb_unlocker/log.rb
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/xscreen_usb_unlocker/log.rb', line 9
def initialize
@options = {}
@options[:utc] = true
@options[:level] = ::Logger::DEBUG
@options[:override_puts] = false
@options[:filename] = STDOUT
create_logger
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
20
21
22
23
|
# File 'lib/xscreen_usb_unlocker/log.rb', line 20
def method_missing(sym, *args, &block)
@l.send sym, *args, &block
exit if sym == :fatal
end
|
Instance Method Details
#disable(sym) ⇒ Object
34
35
36
37
|
# File 'lib/xscreen_usb_unlocker/log.rb', line 34
def disable(sym)
raise 'NoSuchOption' if @options[sym] == nil
@options[sym] = false
end
|
#enable(sym) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/xscreen_usb_unlocker/log.rb', line 25
def enable(sym)
raise 'NoSuchOption' if @options[sym] == nil
@options[sym] = true
if sym == :override_puts
level ::Logger::DEBUG
end
end
|
#filename(file) ⇒ Object
58
59
60
61
|
# File 'lib/xscreen_usb_unlocker/log.rb', line 58
def filename(file)
@options[:filename] = file
create_logger
end
|
#level(s) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/xscreen_usb_unlocker/log.rb', line 39
def level(s)
level = case s.to_sym
when :fatal then ::Logger::FATAL
when :error then ::Logger::ERROR
when :warn then ::Logger::WARN
when :info then ::Logger::INFO
when :debug then ::Logger::DEBUG
else ::Logger::UNKNOWN
end
@options[:level] = level
@l.level = level
end
|
#override_puts? ⇒ Boolean
53
54
55
56
|
# File 'lib/xscreen_usb_unlocker/log.rb', line 53
def override_puts?
return true if @options[:override_puts]
false
end
|