logviewer 1.4.0 → 1.5.0

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: e840049796961dbaec340da1cd042cd84b6a6f03e460d3fe7f186654d69fe6de
4
- data.tar.gz: d6a800844d7b1deda1c8f3cf890bbcffeca9d6e7c746b38bb535b8b922b707ab
3
+ metadata.gz: b6474de992dc2dea2da7f2dc840c7b8a40ebd00b7bb95d41b5f3c8daf735c825
4
+ data.tar.gz: b77161d3a5ff3ad409d2103fb9244e3e80e04d75f0acea8da23de4d4ca3f8bf4
5
5
  SHA512:
6
- metadata.gz: 2fc6f9364df619503be26dddfe2ca170a3446bf1f6e7b518cd52c305e3cf30f41f128f425de598f51bec005a21ddb3da260e347066338231a9cfa5de9145ec78
7
- data.tar.gz: a05e13067b1ef5e3a97412a9ea7239bdcf5121f7c27b9c6033bce80e570aac2dc5fc2b68e186b21d11f422f7f5898eaf14d16d973f72d04b5be41e3069e4e364
6
+ metadata.gz: 543273a8c965e6263d458d9fb728b8f76aacb9d1dc9d70907ae837d7555c7a428aa076d9e35402e25057696edf6f8d56e3947745ed3549bfdd283d8c169fe35b
7
+ data.tar.gz: 15c08fa5c88dd659e0963efe156a8cc02894cc18b07023851391d880f3935e4211ea0d490917f6b38980bf89d853e3dea974f11b71477b5fa4d7a2bf3d614ec6
data/README.md CHANGED
@@ -27,11 +27,15 @@ gem install logviewer
27
27
  ### Basic Usage
28
28
 
29
29
  ```bash
30
+ # With a specific file
30
31
  logviewer example.ndjson
32
+
33
+ # Without specifying a file (auto-detects most recent .ndjson file)
34
+ logviewer
31
35
  ```
32
36
 
33
37
  This will:
34
- 1. Parse the NDJSON file
38
+ 1. Parse the NDJSON file (or auto-detect the most recent .ndjson file in current directory)
35
39
  2. Include all log levels (debug and above)
36
40
  3. Generate an HTML file in `/tmp/`
37
41
  4. Open the HTML file in your default browser
@@ -44,6 +48,16 @@ logviewer --level info example.ndjson
44
48
 
45
49
  Only shows log entries with level "info" and above (info, warning, error, fatal).
46
50
 
51
+ ### Auto-Detection of Log Files
52
+
53
+ When no file is specified, LogViewer automatically searches the current directory for `.ndjson` files and uses the one with the most recent modification date:
54
+
55
+ ```bash
56
+ logviewer --level info
57
+ ```
58
+
59
+ This will find the most recent `.ndjson` file in the current directory and apply the specified log level filter.
60
+
47
61
  ### Command Line Options
48
62
 
49
63
  - `-l, --level LEVEL`: Set minimum log level (trace, debug, info, warning, error, fatal)
@@ -53,13 +67,16 @@ Only shows log entries with level "info" and above (info, warning, error, fatal)
53
67
  ### Examples
54
68
 
55
69
  ```bash
56
- # Show all logs
70
+ # Show all logs from a specific file
57
71
  logviewer app.ndjson
58
72
 
59
- # Show only warnings and above
60
- logviewer --level warning app.ndjson
73
+ # Auto-detect most recent .ndjson file and show all logs
74
+ logviewer
75
+
76
+ # Auto-detect most recent .ndjson file and show only warnings and above
77
+ logviewer --level warning
61
78
 
62
- # Show only errors and fatal logs
79
+ # Show only errors and fatal logs from specific file
63
80
  logviewer -l error system.ndjson
64
81
 
65
82
  # Show version
@@ -1,3 +1,3 @@
1
1
  module LogViewer
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
data/lib/logviewer.rb CHANGED
@@ -23,7 +23,7 @@ module LogViewer
23
23
 
24
24
  def parse_options
25
25
  OptionParser.new do |opts|
26
- opts.banner = "Usage: logviewer [options] <ndjson_file>"
26
+ opts.banner = "Usage: logviewer [options] [ndjson_file]"
27
27
 
28
28
  opts.on('-l', '--level LEVEL', 'Minimum log level (trace, debug, info, warning, error, fatal)') do |level|
29
29
  level = level.downcase
@@ -48,19 +48,31 @@ module LogViewer
48
48
  end.parse!(@args)
49
49
 
50
50
  if @args.empty?
51
- puts "Error: Please provide an NDJSON file path"
52
- puts "Usage: logviewer [options] <ndjson_file>"
53
- exit 1
51
+ @input_file = find_most_recent_ndjson_file
52
+ if @input_file.nil?
53
+ puts "Error: No .ndjson files found in current directory"
54
+ puts "Usage: logviewer [options] [ndjson_file]"
55
+ exit 1
56
+ end
57
+ puts "No file specified, using most recent .ndjson file: #{@input_file}"
58
+ else
59
+ @input_file = @args[0]
54
60
  end
55
61
 
56
- @input_file = @args[0]
57
-
58
62
  unless File.exist?(@input_file)
59
63
  puts "Error: File not found: #{@input_file}"
60
64
  exit 1
61
65
  end
62
66
  end
63
67
 
68
+ def find_most_recent_ndjson_file
69
+ ndjson_files = Dir.glob('*.ndjson')
70
+ return nil if ndjson_files.empty?
71
+
72
+ # Sort by modification time (most recent first) and return the first one
73
+ ndjson_files.max_by { |file| File.mtime(file) }
74
+ end
75
+
64
76
  def should_include_log?(level)
65
77
  return true unless level
66
78
  LOG_LEVELS[level.downcase] >= LOG_LEVELS[@min_level]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logviewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Bishop