rails_log_parser 0.0.19 → 0.0.20

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: c31d67bb8acb5d41820a3938e3c8120e97092721ff97ae969b68aefcd3f9bf1e
4
+ data.tar.gz: dbc3de4762415ee7e4446cec47c83588be62d08b2734b826239a52ab36a610cb
5
5
  SHA512:
6
- metadata.gz: 7be6b87cddbc71826c49fb6b17bfe3d4fbd96bcdb59ca6477adc3caccb7743d59e8a972c1adfa2ce63cc333a9281b91a9402885d77639db52a7080f614a84de7
7
- data.tar.gz: 3847295d29f7de5e40200ed653cb7631a0d9e1bd08e5ad69aa80d1f7cf85496d72bdd165e7f49408aa7993ccb3c0c973a00702be7f01f414af0cdaae522325d0
6
+ metadata.gz: a20c2012e3abd93dbeb5eb7bc09fbb6113e16d664ea426a635775c328ae286360a0cca1cf908b68fd1549fd9ac3bcfb93631da88f48a904fcd5db529109ab91a
7
+ data.tar.gz: 8b930466f378cba8394fd7d8391ad795f153d68d9e544066d5b7c74b3ba26663c3dd5402c782ab5705ebfe5c0e8e75eb60bb91e2803e7ac0c8c67cd1692cb4a8
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,10 @@ end
60
65
 
61
66
  ## Changelog
62
67
 
68
+ ### 0.0.20
69
+
70
+ * Add support for journald
71
+
63
72
  ### 0.0.19
64
73
 
65
74
  * Ignore lines after ActiveJob lines
@@ -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.20'
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.20
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-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: enumerize