log_bench 0.1.0 β 0.1.2
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/README.md +12 -5
- data/exe/log_bench +8 -17
- data/lib/log_bench/app/monitor.rb +0 -2
- data/lib/log_bench/app/renderer/ansi.rb +0 -2
- data/lib/log_bench/app/renderer/details.rb +2 -14
- data/lib/log_bench/app/state.rb +1 -2
- data/lib/log_bench/json_formatter.rb +1 -13
- data/lib/log_bench/log/cache_entry.rb +1 -4
- data/lib/log_bench/log/call_line_entry.rb +0 -3
- data/lib/log_bench/log/entry.rb +3 -2
- data/lib/log_bench/log/query_entry.rb +1 -4
- data/lib/log_bench/railtie.rb +8 -10
- data/lib/log_bench/version.rb +1 -1
- data/lib/tasks/log_bench.rake +20 -18
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 566eefe637e2dce1e46718719b178a044fac2c2e4c368b6ee514b93b8cb0c29c
|
4
|
+
data.tar.gz: 7f4d86b0abddbe4c1a3f694ccf12d1cde3c261b1e87ed940ad0ef21e23cbdf10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82b42f1c7633455d5fc996337a8743cdd8dfaa097b5acccfa115d5b293a0ec527f6aa08f048e62df5b6cb7cd98517fa3b9ce60506b82816d827d13311370ade4
|
7
|
+
data.tar.gz: c90d5d86ec3442e25b9cdd362a21cf56b6a6268ae7dd5b51270b677d44f79574b3ebfcae1c2e9c2861833ff1108776cfb05c3277e93807492db5edc912734e5e
|
data/README.md
CHANGED
@@ -12,7 +12,6 @@ A powerful TUI (Terminal User Interface) for analyzing Rails application logs in
|
|
12
12
|
- π **Performance insights** - duration, allocations, query analysis
|
13
13
|
- π¨ **Beautiful TUI** with syntax highlighting and ANSI color support
|
14
14
|
- β‘ **Fast parsing** of JSON-formatted logs
|
15
|
-
- π§ **Custom logging** support for background jobs and events
|
16
15
|
|
17
16
|
## Installation
|
18
17
|
|
@@ -103,25 +102,33 @@ log_bench log/development.log
|
|
103
102
|
- **Filtering**: `f` to open filter dialog
|
104
103
|
- **Sorting**: `s` to cycle through sort options (timestamp, duration, status)
|
105
104
|
- **Auto-scroll**: `a` to toggle auto-scroll mode
|
106
|
-
- **Clear**: `c` to clear
|
105
|
+
- **Clear**: `c` to clear an active filter (press `escape` or `enter` before pressing `c` to clear)
|
107
106
|
- **Quit**: `q` to exit
|
108
107
|
|
109
108
|
### Filtering
|
110
109
|
|
111
|
-
Press `f` to open the filter dialog.
|
110
|
+
Press `f` to open the filter dialog.
|
111
|
+
|
112
|
+
In the left pane you can filter by:
|
112
113
|
|
113
114
|
- **Method**: GET, POST, PUT, DELETE, etc.
|
114
115
|
- **Path**: URL path patterns
|
115
116
|
- **Status**: HTTP status codes (200, 404, 500, etc.)
|
116
117
|
- **Controller**: Controller name
|
117
118
|
- **Action**: Action name
|
118
|
-
- **
|
119
|
+
- **Request ID**: Unique request identifier
|
119
120
|
|
120
121
|
Examples:
|
121
122
|
- Filter by method: `GET`
|
122
123
|
- Filter by path: `/api/users`
|
123
124
|
- Filter by status: `500`
|
124
|
-
- Filter by
|
125
|
+
- Filter by controller: `UsersController`
|
126
|
+
- Filter by action: `create`
|
127
|
+
- Filter by request ID: `abcdef-b1n2mk ...`
|
128
|
+
|
129
|
+
In the right pane you can filter related log lines by text content to find specific SQL queries or anything else
|
130
|
+
you want to find in the logs.
|
131
|
+
|
125
132
|
|
126
133
|
## Log Format
|
127
134
|
|
data/exe/log_bench
CHANGED
@@ -8,28 +8,19 @@ def show_help
|
|
8
8
|
LogBench - Rails Log Viewer
|
9
9
|
|
10
10
|
Usage:
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
log_bench [log_file]
|
12
|
+
log_bench --help
|
13
|
+
log_bench --version
|
14
14
|
|
15
15
|
Examples:
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
log_bench # View log/development.log
|
17
|
+
log_bench log/production.log # View specific log file
|
18
|
+
log_bench /path/to/app/log/test.log # View log from another app
|
19
19
|
|
20
20
|
Setup (for Rails apps):
|
21
21
|
See README.md for complete configuration instructions:
|
22
22
|
https://github.com/silva96/log_bench#installation
|
23
23
|
|
24
|
-
Custom Logging:
|
25
|
-
# Create JSON loggers for background jobs, events, etc.
|
26
|
-
logger = Logger.new('log/jobs.log')
|
27
|
-
logger.formatter = LogBench::JsonFormatter.new
|
28
|
-
logger.info({ message: "Job completed", job_id: 123 })
|
29
|
-
|
30
|
-
# Then view with LogBench
|
31
|
-
bundle exec log_bench log/jobs.log
|
32
|
-
|
33
24
|
Requirements:
|
34
25
|
- Lograge gem with JSON formatter
|
35
26
|
- Rails application logs in lograge format
|
@@ -64,7 +55,7 @@ begin
|
|
64
55
|
puts " 2. The log file exists and has content"
|
65
56
|
puts " 3. Lograge is configured (see README.md for setup)"
|
66
57
|
puts
|
67
|
-
puts "For help:
|
58
|
+
puts "For help: log_bench --help"
|
68
59
|
exit 1
|
69
60
|
end
|
70
61
|
|
@@ -82,6 +73,6 @@ rescue => e
|
|
82
73
|
puts " - Lograge not configured (see README.md for setup)"
|
83
74
|
puts " - Log format not supported (LogBench requires lograge JSON format)"
|
84
75
|
puts
|
85
|
-
puts "For help:
|
76
|
+
puts "For help: log_bench --help"
|
86
77
|
exit 1
|
87
78
|
end
|
@@ -15,7 +15,6 @@ module LogBench
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def parse_and_render(text, win)
|
18
|
-
# Parse ANSI escape codes and render with proper colors
|
19
18
|
parts = text.split(/(\e\[[0-9;]*m)/)
|
20
19
|
current_color = nil
|
21
20
|
|
@@ -34,7 +33,6 @@ module LogBench
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def wrap_ansi_text(text, max_width)
|
37
|
-
# For ANSI text, we need to preserve color state across chunks
|
38
36
|
clean_text = text.gsub(/\e\[[0-9;]*m/, "")
|
39
37
|
|
40
38
|
if clean_text.length <= max_width
|
@@ -148,22 +148,10 @@ module LogBench
|
|
148
148
|
|
149
149
|
# Add all related logs from the request
|
150
150
|
request.related_logs.each do |log|
|
151
|
-
content = case log
|
152
|
-
when LogBench::Log::QueryEntry, LogBench::Log::CacheEntry, LogBench::Log::CallLineEntry
|
153
|
-
log.content
|
154
|
-
else
|
155
|
-
log.raw_line # Fallback to raw line for other entry types
|
156
|
-
end
|
157
|
-
|
158
|
-
timing = case log
|
159
|
-
when LogBench::Log::QueryEntry, LogBench::Log::CacheEntry
|
160
|
-
log.timing
|
161
|
-
end
|
162
|
-
|
163
151
|
related << {
|
164
152
|
type: log.type,
|
165
|
-
content: content,
|
166
|
-
timing: timing,
|
153
|
+
content: log.content,
|
154
|
+
timing: log.timing,
|
167
155
|
timestamp: log.timestamp
|
168
156
|
}
|
169
157
|
end
|
data/lib/log_bench/app/state.rb
CHANGED
@@ -100,20 +100,19 @@ module LogBench
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def filtered_requests
|
103
|
-
# First apply filter - match exactly like original logtail
|
104
103
|
filtered = if main_filter.present?
|
105
104
|
requests.select do |req|
|
106
105
|
main_filter.matches?(req.path) ||
|
107
106
|
main_filter.matches?(req.method) ||
|
108
107
|
main_filter.matches?(req.controller) ||
|
109
108
|
main_filter.matches?(req.action) ||
|
109
|
+
main_filter.matches?(req.status) ||
|
110
110
|
main_filter.matches?(req.request_id)
|
111
111
|
end
|
112
112
|
else
|
113
113
|
requests
|
114
114
|
end
|
115
115
|
|
116
|
-
# Then apply sorting using Sort domain object
|
117
116
|
sort.sort_requests(filtered)
|
118
117
|
end
|
119
118
|
|
@@ -3,14 +3,7 @@
|
|
3
3
|
require "json"
|
4
4
|
|
5
5
|
module LogBench
|
6
|
-
# A simple JSON formatter for Rails loggers that creates LogBench-compatible
|
7
|
-
# for non-request logging (background jobs, custom events, etc.)
|
8
|
-
#
|
9
|
-
# Usage:
|
10
|
-
# logger = Logger.new(Rails.root.join('log', 'custom.log'))
|
11
|
-
# logger.formatter = LogBench::JsonFormatter.new
|
12
|
-
# logger.info("Background job completed", job_id: 123)
|
13
|
-
#
|
6
|
+
# A simple JSON formatter for Rails loggers that creates LogBench-compatible
|
14
7
|
class JsonFormatter < ::Logger::Formatter
|
15
8
|
def call(severity, timestamp, progname, message)
|
16
9
|
log_entry = build_log_entry(severity, timestamp, progname, message)
|
@@ -54,10 +47,8 @@ module LogBench
|
|
54
47
|
end
|
55
48
|
|
56
49
|
def lograge_message?(entry)
|
57
|
-
# Check if the message field contains lograge JSON
|
58
50
|
return false unless entry[:message].is_a?(String) && entry[:message].start_with?("{")
|
59
51
|
|
60
|
-
# Try to parse and check for lograge fields
|
61
52
|
begin
|
62
53
|
parsed = JSON.parse(entry[:message])
|
63
54
|
parsed.is_a?(Hash) && parsed["method"] && parsed["path"] && parsed["status"]
|
@@ -67,14 +58,12 @@ module LogBench
|
|
67
58
|
end
|
68
59
|
|
69
60
|
def parse_lograge_message(message_string)
|
70
|
-
# Parse the lograge JSON string
|
71
61
|
JSON.parse(message_string)
|
72
62
|
rescue JSON::ParserError
|
73
63
|
nil
|
74
64
|
end
|
75
65
|
|
76
66
|
def current_request_id
|
77
|
-
# Try multiple ways to get the current request ID
|
78
67
|
request_id = nil
|
79
68
|
|
80
69
|
if defined?(Current) && Current.respond_to?(:request_id)
|
@@ -85,7 +74,6 @@ module LogBench
|
|
85
74
|
request_id = Thread.current[:request_id]
|
86
75
|
end
|
87
76
|
|
88
|
-
# Return nil if no request ID found - let caller decide whether to generate UUID
|
89
77
|
request_id
|
90
78
|
end
|
91
79
|
end
|
@@ -5,8 +5,6 @@ module LogBench
|
|
5
5
|
class CacheEntry < Entry
|
6
6
|
SQL_OPERATIONS = %w[SELECT INSERT UPDATE DELETE].freeze
|
7
7
|
|
8
|
-
attr_reader :content, :timing
|
9
|
-
|
10
8
|
def initialize(raw_line)
|
11
9
|
super
|
12
10
|
self.type = :cache
|
@@ -47,8 +45,7 @@ module LogBench
|
|
47
45
|
|
48
46
|
private
|
49
47
|
|
50
|
-
|
51
|
-
attr_writer :content, :timing, :operation
|
48
|
+
attr_writer :operation
|
52
49
|
|
53
50
|
def extract_from_json(data)
|
54
51
|
super
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module LogBench
|
4
4
|
module Log
|
5
5
|
class CallLineEntry < Entry
|
6
|
-
attr_reader :content
|
7
|
-
|
8
6
|
def initialize(raw_line)
|
9
7
|
super
|
10
8
|
self.type = :sql_call_line
|
@@ -30,7 +28,6 @@ module LogBench
|
|
30
28
|
|
31
29
|
private
|
32
30
|
|
33
|
-
attr_writer :content
|
34
31
|
attr_accessor :file_path, :line_number, :method_name
|
35
32
|
|
36
33
|
def extract_from_json(data)
|
data/lib/log_bench/log/entry.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module LogBench
|
4
4
|
module Log
|
5
5
|
class Entry
|
6
|
-
attr_reader :type, :raw_line, :request_id, :timestamp
|
6
|
+
attr_reader :type, :raw_line, :request_id, :timestamp, :content, :timing
|
7
7
|
|
8
8
|
def initialize(raw_line)
|
9
9
|
self.raw_line = raw_line.strip
|
@@ -42,7 +42,7 @@ module LogBench
|
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
|
-
attr_writer :type, :raw_line, :timestamp, :request_id
|
45
|
+
attr_writer :type, :raw_line, :timestamp, :request_id, :content, :timing
|
46
46
|
|
47
47
|
def parse!
|
48
48
|
parse_json
|
@@ -64,6 +64,7 @@ module LogBench
|
|
64
64
|
|
65
65
|
self.timestamp = parse_timestamp(data["timestamp"])
|
66
66
|
self.request_id = data["request_id"]
|
67
|
+
self.content = data["message"]
|
67
68
|
self.type = determine_json_type(data)
|
68
69
|
true
|
69
70
|
end
|
@@ -14,8 +14,6 @@ module LogBench
|
|
14
14
|
SAVEPOINT = "SAVEPOINT"
|
15
15
|
SQL_OPERATIONS = [SELECT, INSERT, UPDATE, DELETE, TRANSACTION, BEGIN_TRANSACTION, COMMIT, ROLLBACK, SAVEPOINT].freeze
|
16
16
|
|
17
|
-
attr_reader :content, :timing
|
18
|
-
|
19
17
|
def initialize(raw_line)
|
20
18
|
super
|
21
19
|
self.type = :sql
|
@@ -125,8 +123,7 @@ module LogBench
|
|
125
123
|
|
126
124
|
private
|
127
125
|
|
128
|
-
|
129
|
-
attr_writer :content, :timing, :operation
|
126
|
+
attr_accessor :operation
|
130
127
|
end
|
131
128
|
end
|
132
129
|
end
|
data/lib/log_bench/railtie.rb
CHANGED
@@ -4,10 +4,7 @@ module LogBench
|
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
railtie_name :log_bench
|
6
6
|
|
7
|
-
#
|
8
|
-
generators do
|
9
|
-
require "generators/log_bench/install_generator"
|
10
|
-
end
|
7
|
+
# LogBench uses manual configuration (see README.md)
|
11
8
|
|
12
9
|
# Provide helpful rake tasks
|
13
10
|
rake_tasks do
|
@@ -24,19 +21,20 @@ module LogBench
|
|
24
21
|
Rails.application.config.lograge.enabled
|
25
22
|
puts "β
LogBench is ready to use!"
|
26
23
|
puts "=" * 70
|
27
|
-
puts "View your logs:
|
24
|
+
puts "View your logs: log_bench log/development.log"
|
28
25
|
else
|
29
26
|
|
30
27
|
puts "π LogBench is ready to configure!"
|
31
28
|
puts "=" * 70
|
32
29
|
puts "To start using LogBench:"
|
33
|
-
puts " 1.
|
34
|
-
puts " 2.
|
35
|
-
puts " 3.
|
36
|
-
puts " 4.
|
30
|
+
puts " 1. See README.md for configuration instructions"
|
31
|
+
puts " 2. Configure lograge in config/environments/development.rb"
|
32
|
+
puts " 3. Restart your Rails server"
|
33
|
+
puts " 4. Make some requests to generate logs"
|
34
|
+
puts " 5. View logs: log_bench log/development.log"
|
37
35
|
puts
|
38
36
|
end
|
39
|
-
puts "For help:
|
37
|
+
puts "For help: log_bench --help"
|
40
38
|
puts "=" * 70 + "\n"
|
41
39
|
puts "=" * 70 + "\n"
|
42
40
|
end
|
data/lib/log_bench/version.rb
CHANGED
data/lib/tasks/log_bench.rake
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
namespace :log_bench do
|
2
|
-
desc "
|
2
|
+
desc "Show LogBench configuration instructions"
|
3
3
|
task :install do
|
4
|
-
puts "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
puts "LogBench Configuration Instructions:"
|
5
|
+
puts
|
6
|
+
puts "Please see the README.md for complete setup instructions:"
|
7
|
+
puts "https://github.com/silva96/log_bench#configuration"
|
8
|
+
puts
|
9
|
+
puts "Quick setup:"
|
10
|
+
puts "1. Add 'require \"lograge\"' to config/environments/development.rb"
|
11
|
+
puts "2. Configure lograge and JsonFormatter (see README)"
|
12
|
+
puts "3. Set up Current model and ApplicationController"
|
13
|
+
puts "4. Restart Rails server"
|
13
14
|
end
|
14
15
|
|
15
16
|
desc "Check LogBench configuration"
|
@@ -27,7 +28,7 @@ namespace :log_bench do
|
|
27
28
|
else
|
28
29
|
puts "β οΈ JSON formatter is not configured"
|
29
30
|
puts " LogBench requires JSON format"
|
30
|
-
puts "
|
31
|
+
puts " See README.md for configuration instructions"
|
31
32
|
end
|
32
33
|
|
33
34
|
# Check if log file exists and has content
|
@@ -41,15 +42,16 @@ namespace :log_bench do
|
|
41
42
|
|
42
43
|
puts
|
43
44
|
puts "π LogBench is ready to use!"
|
44
|
-
puts " Command:
|
45
|
+
puts " Command: log_bench #{log_file}"
|
45
46
|
else
|
46
47
|
puts "β Lograge is not enabled"
|
47
48
|
puts
|
48
49
|
puts "To fix this:"
|
49
|
-
puts " 1.
|
50
|
-
puts " 2.
|
51
|
-
puts " 3.
|
52
|
-
puts " 4.
|
50
|
+
puts " 1. See README.md for configuration instructions"
|
51
|
+
puts " 2. Configure lograge in config/environments/development.rb"
|
52
|
+
puts " 3. Restart your Rails server"
|
53
|
+
puts " 4. Make some requests"
|
54
|
+
puts " 5. Run: log_bench log/development.log"
|
53
55
|
end
|
54
56
|
puts "=" * 60 + "\n"
|
55
57
|
end
|
@@ -66,8 +68,8 @@ namespace :log_bench do
|
|
66
68
|
2. Run bundle install:
|
67
69
|
bundle install
|
68
70
|
|
69
|
-
3. Configure lograge:
|
70
|
-
|
71
|
+
3. Configure lograge (see README.md):
|
72
|
+
https://github.com/silva96/log_bench#configuration
|
71
73
|
|
72
74
|
4. Restart your Rails server
|
73
75
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_bench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BenjamΓn Silva
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-06-
|
10
|
+
date: 2025-06-06 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: zeitwerk
|
@@ -148,8 +148,8 @@ metadata:
|
|
148
148
|
documentation_uri: https://github.com/silva96/log_bench/blob/main/README.md
|
149
149
|
post_install_message: "\n\U0001F389 LogBench installed successfully!\n\nNext steps:\n1.
|
150
150
|
Configure Rails (see README.md for setup instructions)\n2. Restart your Rails server\n3.
|
151
|
-
Make some requests to generate logs\n4. View logs:
|
152
|
-
help:
|
151
|
+
Make some requests to generate logs\n4. View logs: log_bench log/development.log\n\nFor
|
152
|
+
help: log_bench --help\nDocumentation: https://github.com/silva96/log_bench\n\n"
|
153
153
|
rdoc_options: []
|
154
154
|
require_paths:
|
155
155
|
- lib
|