Module: SolidLog::UI::TimelineHelper

Defined in:
app/helpers/solid_log/ui/timeline_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_timeline_duration(duration_ms) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/solid_log/ui/timeline_helper.rb', line 11

def format_timeline_duration(duration_ms)
  return "N/A" if duration_ms.nil?

  if duration_ms < 1
    "< 1ms"
  elsif duration_ms < 1000
    format("%.1fms", duration_ms)
  else
    format("%.1fs", duration_ms / 1000.0)
  end
end

#timeline_duration_bar(duration, max_duration) ⇒ Object



4
5
6
7
8
9
# File 'app/helpers/solid_log/ui/timeline_helper.rb', line 4

def timeline_duration_bar(duration, max_duration)
  return "" if duration.nil? || max_duration.nil? || max_duration.zero?

  width_percentage = [(duration.to_f / max_duration * 100), 100].min
  (:div, "", class: "timeline-duration-bar", style: "width: #{format('%.1f', width_percentage)}%")
end

#timeline_event_icon(entry) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/solid_log/ui/timeline_helper.rb', line 23

def timeline_event_icon(entry)
  case entry.level
  when "error", "fatal"
    "⚠️"
  when "warn"
    "⚡"
  when "info"
    "ℹ️"
  when "debug"
    "🔍"
  else
    "•"
  end
end