Class: DevSystem::LogPanel
Instance Attribute Summary
Attributes inherited from Liza::Panel
#key
Instance Method Summary
collapse
Methods inherited from Liza::Panel
#box, box, color, controller, #controller, division, #division, #initialize, instance, #push, #started, subsystem, #subsystem, token
Methods inherited from Liza::Unit
_erbs_for, #add, add, cl, #cl, class_methods_defined, const_added, const_missing, constants_defined, define_error, descendants_select, division, erbs_available, erbs_defined, erbs_for, errors, #fetch, fetch, get, #get, instance_methods_defined, log, #log, log?, #log?, #log_array, log_array, log_hash, #log_hash, #log_level, log_level, #log_level?, log_level?, log_levels, #log_levels, #log_render_convert, #log_render_format, #log_render_in, #log_render_out, method_added, methods_defined, namespace, part, raise_error, #raise_error, reload!, #reload!, #render, #render!, #render_stack, renderable_formats_for, renderable_names, section, sections, #set, set, #settings, settings, singleton_method_added, sleep, #sleep, stick, #stick, sticks, #sticks, subclasses_select, subunits, system, #system, system?, test_class, time_diff, #time_diff
Constructor Details
This class inherits a constructor from Liza::Panel
Instance Method Details
#call(env) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 3
def call env
env[:instance] ||= env[:unit_class] != env[:unit]
env[:method_name] ||= method_name_for env
env[:method_name] = env[:method_name].to_s
return unless env[:message_log_level] <= env[:unit_log_level]
return if handlers.empty?
find env
parse env
handlers.values.each do |handler|
handler.call env
rescue Exception => e
log stick :light_yellow, "#{e.class} #{e.message.inspect} on #{e.backtrace[0]}"
end
end
|
#find(env) ⇒ Object
25
26
27
28
29
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 25
def find env
env[:object_log] = Liza.const "#{env[:object_class].last_namespace}_log"
rescue Liza::ConstNotFound
env[:object_log] = StickLogLog
end
|
#handler(*keys) ⇒ Object
35
36
37
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 35
def handler *keys
handler_keys.concat keys
end
|
#handler_keys ⇒ Object
39
40
41
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 39
def handler_keys
@handler_keys ||= []
end
|
#handlers ⇒ Object
43
44
45
46
47
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 43
def handlers
@handlers ||= handler_keys.map do |k|
[k, Liza.const("#{k}_handler_log")]
end.to_h
end
|
#method_name_for(env) ⇒ Object
NOTE: improve logs performance and readability
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 59
def method_name_for env
env[:caller].each do |s|
t = s.match(/`(.*)'/)[1]
next if t.include? " in <class:"
return t.split(" ").last if t.include? " in "
next if t == "log"
next if t == "each"
next if t == "map"
next if t == "with_index"
next if t == "instance_exec"
next if t.start_with? "_"
return t
end
raise "there's something wrong with kaller"
end
|
#parse(env) ⇒ Object
31
32
33
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 31
def parse env
env[:object_log].call env
end
|
49
50
51
52
53
54
55
|
# File 'lib/dev_system/subsystems/log/log_panel.rb', line 49
def = nil
if
@sidebar_size =
else
@sidebar_size
end
end
|