Class: DevSystem::OutputLog

Inherits:
Log show all
Defined in:
lib/dev_system/sub/log/logs/output_log.rb

Constant Summary collapse

60

Class Method Summary collapse

Methods inherited from Liza::Controller

color, inherited, on_connected

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Class Method Details

.call(env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dev_system/sub/log/logs/output_log.rb', line 5

def self.call(env)
  env[:sidebar] ||= sidebar_for env

  string = env[:object]
  string = string.join("") if string.is_a? Array

  unless $coding
    pid = Process.pid
    tid = Lizarb.thread_id.to_s.rjust_zeroes 3
    env[:sidebar] = "#{pid} #{tid} #{env[:sidebar]}"
  end

  string = "#{env[:sidebar]} #{string}"
  Kernel.puts string
end


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/dev_system/sub/log/logs/output_log.rb', line 21

def self.sidebar_for env
  sidebar = ""

  source = env[:unit_class]
  system_color = source.system.color
  source_color = source.division.system.color
  size = 0

  # TODO: Figure out why RequestPanel is returning false when started from rack command but not from request command
  # source_is_a_panel = source < Panel
  # source_is_a_panel = source.ancestors.include? Panel
  # source_is_a_panel = env[:unit].is_a? Panel
  source_is_a_panel = source.to_s.end_with? "Panel"

  if source_is_a_panel
    key = env[:unit].key
    source = source.box

    namespace, _sep, classname = source.name.rpartition('::')
    unless namespace.empty?
      sidebar << stick(namespace, system_color, :b).to_s
      sidebar << "::"
      size += namespace.size + 2
    end
    sidebar << stick(classname, source_color).to_s
    sidebar << "[:#{key}]."

    size += classname.size + key.size + 4
  else
    method_sep = env[:instance] ? "#" : ":"

    namespace, _sep, classname = env[:unit_class].name.rpartition('::')
    unless namespace.empty?
      sidebar << stick(namespace, system_color, :b).to_s
      sidebar << "::"
      size += namespace.size + 2
    end
    sidebar << stick(classname, source_color).to_s

    sidebar << method_sep
    size += classname.size + 1
  end

  sidebar << env[:method_name]
  size += env[:method_name].size

  size = SIDEBAR_LENGTH - size - 1
  size = 0 if size < 0
  sidebar << " " * size

  sidebar
end