log_bench 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/log_bench/app/copy_handler.rb +74 -15
- data/lib/log_bench/app/renderer/details.rb +12 -7
- data/lib/log_bench/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfbdd891667f8c0db91b6dc0afd5e7cb4562b941a300d31267dd6cbb973d8257
|
4
|
+
data.tar.gz: 04b3ca23a18b72f7d2798233c53a549788767f92bd40ac7a87214c95a9a1e3ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9d928b2d0c39c584426f8757855b1d51524e0ef0cc5822b84935ba2c228c3f80e5a22b201a1097f92dad422cfe06b1843ca83173307d59785f8345e27cc520
|
7
|
+
data.tar.gz: 0f7bcf9c8f9ceaa040ccb7e9b9b7b2d9a7f570cb1b7d03d2be4c5390dfb26137cc3d6cc358fea903d55c7fd89a2315276a725c8112e80e909d2352c0d75db489
|
@@ -16,6 +16,26 @@ module LogBench
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def find_companion_call_line(request, selected_entry_id)
|
20
|
+
# Get the detail lines for the current request
|
21
|
+
lines = renderer&.get_cached_detail_lines(request)
|
22
|
+
return nil unless lines
|
23
|
+
|
24
|
+
# Find all lines belonging to the selected entry
|
25
|
+
selected_lines = lines.select { |line| line[:entry_id] == selected_entry_id }
|
26
|
+
|
27
|
+
# Look for a call line (starts with "↳") in the same entry group
|
28
|
+
call_line = selected_lines.find do |line|
|
29
|
+
text = line[:text]&.gsub(/\e\[[0-9;]*m/, "")&.strip
|
30
|
+
text&.start_with?("↳")
|
31
|
+
end
|
32
|
+
|
33
|
+
if call_line
|
34
|
+
# Clean and return the call line content
|
35
|
+
call_line[:text].gsub(/\e\[[0-9;]*m/, "").strip
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
19
39
|
private
|
20
40
|
|
21
41
|
attr_accessor :state, :renderer
|
@@ -51,7 +71,7 @@ module LogBench
|
|
51
71
|
request = state.current_request
|
52
72
|
return unless request
|
53
73
|
|
54
|
-
# Get the detail lines for the current request
|
74
|
+
# Get the detail lines for the current request to find entry IDs
|
55
75
|
lines = renderer&.get_cached_detail_lines(request)
|
56
76
|
return unless lines
|
57
77
|
|
@@ -63,24 +83,63 @@ module LogBench
|
|
63
83
|
selected_entry_id = entry_ids[state.detail_selected_entry]
|
64
84
|
return unless selected_entry_id
|
65
85
|
|
66
|
-
# Find
|
86
|
+
# Find lines belonging to the selected entry and look for original_entry reference
|
67
87
|
selected_lines = lines.select { |line| line[:entry_id] == selected_entry_id }
|
68
88
|
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
content_text = content.join(" ")
|
78
|
-
is_sql_query = sql_query?(content_text)
|
89
|
+
# Look for a line that has the original_entry reference
|
90
|
+
original_entry = nil
|
91
|
+
selected_lines.each do |line|
|
92
|
+
if line[:original_entry]
|
93
|
+
original_entry = line[:original_entry]
|
94
|
+
break
|
95
|
+
end
|
96
|
+
end
|
79
97
|
|
80
|
-
if
|
81
|
-
|
98
|
+
if original_entry
|
99
|
+
# Use the original log entry content
|
100
|
+
content = original_entry.content
|
101
|
+
return unless content
|
102
|
+
|
103
|
+
# Remove ANSI escape codes for clean copying
|
104
|
+
clean_content = content.gsub(/\e\[[0-9;]*m/, "").strip
|
105
|
+
|
106
|
+
# Check if this is a SQL query and if there's a companion call line
|
107
|
+
is_sql_query = sql_query?(clean_content)
|
108
|
+
|
109
|
+
if is_sql_query
|
110
|
+
# Look for companion call line in the same entry group
|
111
|
+
call_line_content = find_companion_call_line(request, selected_entry_id)
|
112
|
+
|
113
|
+
if call_line_content
|
114
|
+
# Include both SQL query and call line
|
115
|
+
full_content = "#{clean_content}\n#{call_line_content}"
|
116
|
+
Clipboard.copy("```sql\n#{full_content}\n```")
|
117
|
+
else
|
118
|
+
# Just the SQL query
|
119
|
+
Clipboard.copy("```sql\n#{clean_content}\n```")
|
120
|
+
end
|
121
|
+
else
|
122
|
+
Clipboard.copy(clean_content)
|
123
|
+
end
|
82
124
|
else
|
83
|
-
|
125
|
+
# Fallback to the old method - join wrapped lines but try to reconstruct original
|
126
|
+
content = selected_lines.map do |line|
|
127
|
+
text = line[:text] || ""
|
128
|
+
# Remove ANSI escape codes and trim padding
|
129
|
+
text.gsub(/\e\[[0-9;]*m/, "").strip
|
130
|
+
end.reject(&:empty?)
|
131
|
+
|
132
|
+
# Try to join the content intelligently
|
133
|
+
content_text = content.join(" ").gsub(/\s+/, " ").strip
|
134
|
+
|
135
|
+
# Check if this is a SQL query
|
136
|
+
is_sql_query = sql_query?(content_text)
|
137
|
+
|
138
|
+
if is_sql_query
|
139
|
+
Clipboard.copy("```sql\n#{content_text}\n```")
|
140
|
+
else
|
141
|
+
Clipboard.copy(content_text)
|
142
|
+
end
|
84
143
|
end
|
85
144
|
end
|
86
145
|
|
@@ -439,16 +439,16 @@ module LogBench
|
|
439
439
|
# Check if current log is a SQL/cache query followed by a call source line
|
440
440
|
if [:sql, :cache].include?(current_log.type) && next_log && next_log.type == :sql_call_line
|
441
441
|
# Group the query and call source together with the same entry_id
|
442
|
-
render_padded_text_with_spacing(current_log.content, lines, entry_id, extra_empty_lines: 0)
|
443
|
-
render_padded_text_with_spacing(next_log.content, lines, entry_id, extra_empty_lines: 1, use_separator: true)
|
442
|
+
render_padded_text_with_spacing(current_log.content, lines, entry_id, extra_empty_lines: 0, original_entry: current_log)
|
443
|
+
render_padded_text_with_spacing(next_log.content, lines, entry_id, extra_empty_lines: 1, use_separator: true, original_entry: current_log)
|
444
444
|
i += 2 # Skip the next log since we processed it
|
445
445
|
else
|
446
446
|
# Handle standalone logs
|
447
447
|
case current_log.type
|
448
448
|
when :sql, :cache
|
449
|
-
render_padded_text_with_spacing(current_log.content, lines, entry_id, extra_empty_lines: 0)
|
449
|
+
render_padded_text_with_spacing(current_log.content, lines, entry_id, extra_empty_lines: 0, original_entry: current_log)
|
450
450
|
else
|
451
|
-
render_padded_text_with_spacing(current_log.content, lines, entry_id, extra_empty_lines: 1)
|
451
|
+
render_padded_text_with_spacing(current_log.content, lines, entry_id, extra_empty_lines: 1, original_entry: current_log)
|
452
452
|
end
|
453
453
|
i += 1
|
454
454
|
end
|
@@ -485,7 +485,7 @@ module LogBench
|
|
485
485
|
matched_indices.sort.map { |index| related_logs[index] }
|
486
486
|
end
|
487
487
|
|
488
|
-
def render_padded_text_with_spacing(text, lines, entry_id, extra_empty_lines: 1, use_separator: false)
|
488
|
+
def render_padded_text_with_spacing(text, lines, entry_id, extra_empty_lines: 1, use_separator: false, original_entry: nil)
|
489
489
|
# Helper function that renders text with padding, breaking long text into multiple lines
|
490
490
|
content_width = detail_win.maxx - 8 # Account for padding (4 spaces each side)
|
491
491
|
|
@@ -501,12 +501,17 @@ module LogBench
|
|
501
501
|
end
|
502
502
|
|
503
503
|
# Render each chunk as a separate line with padding
|
504
|
-
text_chunks.
|
505
|
-
|
504
|
+
text_chunks.each_with_index do |chunk, index|
|
505
|
+
line_data = if has_ansi
|
506
506
|
{text: " #{chunk} ", color: nil, raw_ansi: true, entry_id: entry_id}
|
507
507
|
else
|
508
508
|
{text: " #{chunk} ", color: nil, entry_id: entry_id}
|
509
509
|
end
|
510
|
+
|
511
|
+
# Add original_entry reference to the first line of each entry
|
512
|
+
line_data[:original_entry] = original_entry if index == 0 && original_entry
|
513
|
+
|
514
|
+
lines << line_data
|
510
515
|
end
|
511
516
|
|
512
517
|
# Add extra empty lines after all chunks
|
data/lib/log_bench/version.rb
CHANGED