rails_log_parser 0.0.19 → 0.0.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17f49e17db36b928e5e9f3f64a22fca9388ce9dc9374d3d0fc5a20c2a9e7e16c
4
- data.tar.gz: fcd9335cadedddf9c093b159f432c9cca6acfd99f080af691ea14bbbc77bb8da
3
+ metadata.gz: 6570aad9bd2c13fe7c8e86ad2ddece7a64319043122e195b2ce57fb89916cb44
4
+ data.tar.gz: 0e70389c743ca8f08bcd581726e3b48741ebe690b320b63d5bcdd0ef31955af2
5
5
  SHA512:
6
- metadata.gz: 7be6b87cddbc71826c49fb6b17bfe3d4fbd96bcdb59ca6477adc3caccb7743d59e8a972c1adfa2ce63cc333a9281b91a9402885d77639db52a7080f614a84de7
7
- data.tar.gz: 3847295d29f7de5e40200ed653cb7631a0d9e1bd08e5ad69aa80d1f7cf85496d72bdd165e7f49408aa7993ccb3c0c973a00702be7f01f414af0cdaae522325d0
6
+ metadata.gz: 422df67cbf2cf72dbe7a84a1fe7bf865a9895010ef220c19f2c9c6209ca3b1d4b450ef3c52f38ad8facc4f5b5b89c89a08bcace3ad12701a0e8daf695b5cac2a
7
+ data.tar.gz: c5d900bd03d0c6786972ba3ef4b1b399bb47fe015b5697e31d3e270a9ec942f89b6ce07809c4df92fbdc4e96cde842d973a53426c5de74f46663d7be99cb1f16
data/README.md CHANGED
@@ -45,6 +45,11 @@ parser = RailsLogParser::Parser.from_file(log_path)
45
45
  print parser.summary(last_minutes: 22) # print summary for the last 22 minutes
46
46
  ```
47
47
 
48
+ ```ruby
49
+ parser = RailsLogParser::Parser.from_journalctl(unit: "myapp.service", since: "1 hour ago")
50
+ print parser.summary(last_minutes: 22) # print summary for the last 22 minutes
51
+ ```
52
+
48
53
  You can configure filters:
49
54
 
50
55
  ```ruby
@@ -60,6 +65,14 @@ end
60
65
 
61
66
  ## Changelog
62
67
 
68
+ ### 0.0.21
69
+
70
+ * Use `ignore_lines` on not parsable lines
71
+
72
+ ### 0.0.20
73
+
74
+ * Add support for journald
75
+
63
76
  ### 0.0.19
64
77
 
65
78
  * Ignore lines after ActiveJob lines
@@ -12,7 +12,7 @@ class RailsLogParser::NotParseableLines
12
12
  end
13
13
 
14
14
  def push(line)
15
- @lines.push(line) unless today_lines.include?(line)
15
+ @lines.push(line) unless ignore?(line)
16
16
  end
17
17
 
18
18
  def save
@@ -31,6 +31,12 @@ class RailsLogParser::NotParseableLines
31
31
  @stats[Date.today.to_s] || []
32
32
  end
33
33
 
34
+ def ignore?(line)
35
+ return true if today_lines.include?(line)
36
+
37
+ RailsLogParser.ignore_lines.any? {|ignore| line.match?(ignore) }
38
+ end
39
+
34
40
  def load_file
35
41
  @stats = JSON.parse(File.read(@path))
36
42
  @stats ||= {}
@@ -8,15 +8,31 @@ class RailsLogParser::Parser
8
8
  @log_path || ENV['LOG_PATH'] || raise('no log_path given')
9
9
  end
10
10
 
11
- def from_file(path)
11
+ def from_io(io)
12
12
  parser = new
13
- File.open(path, 'r') do |handle|
14
- while (line = handle.gets)
15
- parser.puts(line)
16
- end
13
+
14
+ io.each_line do |line|
15
+ parser.puts(line)
17
16
  end
17
+
18
18
  parser
19
19
  end
20
+
21
+ def from_file(path)
22
+ File.open(path, 'r') do |file|
23
+ from_io(file)
24
+ end
25
+ end
26
+
27
+ def from_journalctl(unit:, since: nil)
28
+ cmd = ["journalctl", "-u", unit, "-o", "cat"]
29
+
30
+ cmd += ["--since", since] if since
31
+
32
+ IO.popen(cmd, err: [:child, :out]) do |io|
33
+ from_io(io)
34
+ end
35
+ end
20
36
  end
21
37
 
22
38
  attr_reader :not_parseable_lines, :last_action
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'rails_log_parser'
5
- spec.version = '0.0.19'
5
+ spec.version = '0.0.21'
6
6
  spec.authors = ['Georg Limbach']
7
7
  spec.email = ['georg.limbach@lichtbit.com']
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_log_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Limbach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-27 00:00:00.000000000 Z
11
+ date: 2026-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: enumerize