solid_log-core 0.1.0 → 0.2.1
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/puma/plugin/solid_log.rb +151 -0
- data/lib/solid_log/core/configuration.rb +12 -2
- data/lib/solid_log/core/jobs/cache_cleanup_job.rb +48 -0
- data/lib/solid_log/core/jobs/field_analysis_job.rb +58 -0
- data/lib/solid_log/core/jobs/parse_job.rb +105 -0
- data/lib/solid_log/core/jobs/retention_job.rb +63 -0
- data/lib/solid_log/core/services/batch_parsing_service.rb +248 -0
- data/lib/solid_log/core/services/field_analyzer.rb +1 -1
- data/lib/solid_log/core/services/migration_generator.rb +160 -0
- data/lib/solid_log/core/services/migration_runner.rb +147 -0
- data/lib/solid_log/core/services/retention_service.rb +12 -1
- data/lib/solid_log/core/version.rb +1 -1
- data/lib/solid_log/core.rb +36 -0
- data/lib/solid_log/direct_logger.rb +8 -0
- data/lib/solid_log/models/field.rb +7 -1
- data/lib/solid_log/models/raw_entry.rb +2 -2
- data/lib/solid_log/models/token.rb +1 -1
- data/lib/solid_log/railtie.rb +71 -0
- data/lib/solid_log/silence_middleware.rb +32 -17
- metadata +11 -2
|
@@ -25,8 +25,14 @@ module SolidLog
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# Mark field as promoted (has its own column)
|
|
28
|
+
# Automatically generates a migration file to add the column
|
|
28
29
|
def promote!
|
|
29
|
-
|
|
30
|
+
transaction do
|
|
31
|
+
update!(promoted: true)
|
|
32
|
+
|
|
33
|
+
# Generate migration file for this promotion
|
|
34
|
+
MigrationGenerator.generate_promotion_migration(self)
|
|
35
|
+
end
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
# Mark field as unpromoted (stored in JSON)
|
|
@@ -16,7 +16,7 @@ module SolidLog
|
|
|
16
16
|
def payload_hash
|
|
17
17
|
@payload_hash ||= JSON.parse(payload)
|
|
18
18
|
rescue JSON::ParserError => e
|
|
19
|
-
|
|
19
|
+
SolidLog.logger.error "SolidLog: Failed to parse payload for RawEntry #{id}: #{e.message}"
|
|
20
20
|
{}
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ module SolidLog
|
|
|
26
26
|
def self.claim_batch(batch_size: 100)
|
|
27
27
|
SolidLog.adapter.claim_batch(batch_size)
|
|
28
28
|
rescue => e
|
|
29
|
-
|
|
29
|
+
SolidLog.logger.error "SolidLog: Failed to claim batch: #{e.message}"
|
|
30
30
|
[]
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -54,7 +54,7 @@ module SolidLog
|
|
|
54
54
|
# Generate deterministic hash using HMAC-SHA256
|
|
55
55
|
# This allows O(1) database lookups while maintaining security
|
|
56
56
|
def self.hash_token(plaintext)
|
|
57
|
-
secret_key =
|
|
57
|
+
secret_key = ENV["SOLIDLOG_SECRET_KEY"] || raise("SOLIDLOG_SECRET_KEY environment variable not set")
|
|
58
58
|
OpenSSL::HMAC.hexdigest("SHA256", secret_key, plaintext)
|
|
59
59
|
end
|
|
60
60
|
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/railtie"
|
|
4
|
+
|
|
5
|
+
module SolidLog
|
|
6
|
+
class Railtie < Rails::Railtie
|
|
7
|
+
# Silence SolidLog's internal operations in ALL environments
|
|
8
|
+
# This prevents noise from SolidLog's own SQL queries, transactions, and view rendering
|
|
9
|
+
initializer "solid_log.silence_internal_logs", after: :load_config_initializers do
|
|
10
|
+
ActiveSupport.on_load(:active_record) do
|
|
11
|
+
SolidLog::Railtie.silence_sql_and_transaction_logs
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Silence view logs after Rails has fully initialized
|
|
16
|
+
# This ensures ActionView::LogSubscriber is loaded and instantiated
|
|
17
|
+
config.after_initialize do
|
|
18
|
+
SolidLog::Railtie.silence_view_rendering_logs
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class << self
|
|
22
|
+
def silence_view_rendering_logs
|
|
23
|
+
return unless defined?(ActionView::LogSubscriber)
|
|
24
|
+
|
|
25
|
+
# Silence "Rendering..." messages (logged at start)
|
|
26
|
+
ActionView::LogSubscriber::Start.prepend(Module.new do
|
|
27
|
+
def start(name, id, payload)
|
|
28
|
+
return if payload[:identifier]&.include?("solid_log")
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
end) if defined?(ActionView::LogSubscriber::Start)
|
|
32
|
+
|
|
33
|
+
# Silence "Rendered..." messages (logged at completion)
|
|
34
|
+
ActionView::LogSubscriber.prepend(Module.new do
|
|
35
|
+
def render_template(event)
|
|
36
|
+
return if event.payload[:identifier]&.include?("solid_log")
|
|
37
|
+
super
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def render_layout(event)
|
|
41
|
+
return if event.payload[:identifier]&.include?("solid_log")
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def render_partial(event)
|
|
46
|
+
return if event.payload[:identifier]&.include?("solid_log")
|
|
47
|
+
super
|
|
48
|
+
end
|
|
49
|
+
end)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def silence_sql_and_transaction_logs
|
|
53
|
+
return unless defined?(ActiveRecord::LogSubscriber)
|
|
54
|
+
|
|
55
|
+
ActiveRecord::LogSubscriber.prepend(Module.new do
|
|
56
|
+
def sql(event)
|
|
57
|
+
# Skip SolidLog table queries
|
|
58
|
+
sql_query = event.payload[:sql]
|
|
59
|
+
return if sql_query&.match?(/solid_log_(entries|raw|fields|facet_cache|tokens)/i)
|
|
60
|
+
return if event.payload[:name]&.include?("SolidLog")
|
|
61
|
+
|
|
62
|
+
# Skip all transaction logs (BEGIN/COMMIT/ROLLBACK)
|
|
63
|
+
return if event.payload[:name] == "TRANSACTION" && Rails.env.development?
|
|
64
|
+
|
|
65
|
+
super
|
|
66
|
+
end
|
|
67
|
+
end)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -5,30 +5,45 @@ module SolidLog
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def call(env)
|
|
8
|
-
|
|
8
|
+
# Set thread-local flag BEFORE calling next middleware
|
|
9
|
+
# This ensures it's set when the controller/logger runs
|
|
10
|
+
Thread.current[:solid_log_silenced] = true if should_silence?(env)
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# Set thread-local flag to prevent SolidLog from logging its own requests
|
|
13
|
-
Thread.current[:solid_log_silenced] = true
|
|
12
|
+
begin
|
|
13
|
+
status, headers, body = @app.call(env)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
else
|
|
21
|
-
@app.call(env)
|
|
15
|
+
# Return response
|
|
16
|
+
[status, headers, body]
|
|
17
|
+
ensure
|
|
18
|
+
Thread.current[:solid_log_silenced] = nil
|
|
22
19
|
end
|
|
23
20
|
end
|
|
24
21
|
|
|
25
22
|
private
|
|
26
23
|
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
def should_silence?(env)
|
|
25
|
+
path = env["PATH_INFO"] || ""
|
|
26
|
+
|
|
27
|
+
# Check path patterns for SolidLog UI and API routes
|
|
28
|
+
# Match common mount points: /admin/logs, /solid_log, /solidlog, /logs/*
|
|
29
|
+
# Also match API routes: /api/v1/ingest, /api/v1/logs
|
|
30
|
+
path.start_with?("/admin/logs") ||
|
|
31
|
+
path.include?("solid_log") ||
|
|
32
|
+
path.include?("solidlog") ||
|
|
33
|
+
path.start_with?("/api/v1/ingest") ||
|
|
34
|
+
path.start_with?("/api/v1/logs") ||
|
|
35
|
+
(path.start_with?("/logs/") && solid_log_ui_route?(path))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def solid_log_ui_route?(path)
|
|
39
|
+
# Common SolidLog UI routes when mounted at /logs
|
|
40
|
+
path.include?("/streams") ||
|
|
41
|
+
path.include?("/entries") ||
|
|
42
|
+
path.include?("/fields") ||
|
|
43
|
+
path.include?("/search") ||
|
|
44
|
+
path.include?("/export") ||
|
|
45
|
+
path == "/logs" ||
|
|
46
|
+
path == "/logs/"
|
|
32
47
|
end
|
|
33
48
|
end
|
|
34
49
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solid_log-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dan Loman
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -186,6 +186,7 @@ files:
|
|
|
186
186
|
- db/log_structure_sqlite.sql
|
|
187
187
|
- lib/generators/solid_log/install/install_generator.rb
|
|
188
188
|
- lib/generators/solid_log/install/templates/solid_log.rb.tt
|
|
189
|
+
- lib/puma/plugin/solid_log.rb
|
|
189
190
|
- lib/solid_log-core.rb
|
|
190
191
|
- lib/solid_log/adapters/adapter_factory.rb
|
|
191
192
|
- lib/solid_log/adapters/base_adapter.rb
|
|
@@ -200,9 +201,16 @@ files:
|
|
|
200
201
|
- lib/solid_log/core/client/lograge_formatter.rb
|
|
201
202
|
- lib/solid_log/core/client/retry_handler.rb
|
|
202
203
|
- lib/solid_log/core/configuration.rb
|
|
204
|
+
- lib/solid_log/core/jobs/cache_cleanup_job.rb
|
|
205
|
+
- lib/solid_log/core/jobs/field_analysis_job.rb
|
|
206
|
+
- lib/solid_log/core/jobs/parse_job.rb
|
|
207
|
+
- lib/solid_log/core/jobs/retention_job.rb
|
|
208
|
+
- lib/solid_log/core/services/batch_parsing_service.rb
|
|
203
209
|
- lib/solid_log/core/services/correlation_service.rb
|
|
204
210
|
- lib/solid_log/core/services/field_analyzer.rb
|
|
205
211
|
- lib/solid_log/core/services/health_service.rb
|
|
212
|
+
- lib/solid_log/core/services/migration_generator.rb
|
|
213
|
+
- lib/solid_log/core/services/migration_runner.rb
|
|
206
214
|
- lib/solid_log/core/services/retention_service.rb
|
|
207
215
|
- lib/solid_log/core/services/search_service.rb
|
|
208
216
|
- lib/solid_log/core/version.rb
|
|
@@ -214,6 +222,7 @@ files:
|
|
|
214
222
|
- lib/solid_log/models/record.rb
|
|
215
223
|
- lib/solid_log/models/token.rb
|
|
216
224
|
- lib/solid_log/parser.rb
|
|
225
|
+
- lib/solid_log/railtie.rb
|
|
217
226
|
- lib/solid_log/silence_middleware.rb
|
|
218
227
|
homepage: https://github.com/namolnad/solid_log
|
|
219
228
|
licenses:
|