logm 0.0.4 → 0.0.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/logm +5 -1
  3. data/lib/logmerge.rb +9 -10
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8268e85c780fcb505648e7f36ef915b0b82a253907148a2f95485a690bef294
4
- data.tar.gz: 90042d98654e802e6c694de035297c120c2fbc74c65a0d69f95a330d3927a312
3
+ metadata.gz: 4dca096ee5abe2f77c4f7ff1e746d3a62392ff51cdad344aded0d170abcc4aaa
4
+ data.tar.gz: cdb8027b35fe79d15be8918ab52f8e10a616528755c9d07c8bb2952c0bc58f36
5
5
  SHA512:
6
- metadata.gz: e6966a36051254dee8b55b0196250b4d682f8e136f8da76525dbab6a045953873915d541523827e74f8d6e6b7a4c0760f0758a4da94d1f2fa5ecedb953bfa340
7
- data.tar.gz: 3d163efc23ee1868c288074ab553dbc2622fbc8b17b1401213eea97b6e7e77e4e9eddba2988de6274164931b8a2932f3698562fd118cc9f18fd143b49db3e439
6
+ metadata.gz: 665aad4a847b0de8537c0e0e137d401165f0dc62014a4b79123f871838dff4a46acdc142c0a7340b25f58e9e9394281863ccbb3308ea1b32c3c2451b68d2f9b6
7
+ data.tar.gz: 6657a1b8d915cfb2e07fb2eebfde55c88032b2b4c0fbcd81dde2f2bac792fc01f655788d0d8468c863d2113a841092553746aac3db63c7d5f34ccd1df1f45b40
data/bin/logm CHANGED
@@ -11,10 +11,14 @@ OptionParser.new do |opts|
11
11
  opts.on("-eENDTIME", "--endTime=ENDTIME", "endTime") do |time|
12
12
  options[:endTime] = time
13
13
  end
14
+ opts.on("-a", "--autotag", "endTime") do
15
+ options[:autotag] = true
16
+ end
14
17
  end.parse!
15
18
 
16
19
  options[:startTime] ||= Time.at(0)
17
20
  options[:endTime] ||= Time.at(2000000000000)
21
+ options[:autotag] ||= false
18
22
 
19
- merge = LogMerge.new(ARGV, options[:startTime], options[:endTime])
23
+ merge = LogMerge.new(ARGV, options[:startTime], options[:endTime], options[:autotag])
20
24
  merge.merge
@@ -36,7 +36,7 @@ end
36
36
 
37
37
  class Log
38
38
  attr_accessor :file, :line, :next, :offet, :tag, :timestamp, :next_timestamp, :finished
39
- def initialize(path)
39
+ def initialize(path, autotag=false)
40
40
  @offset = 0
41
41
  if path.include?(':')
42
42
  parts = path.split(':')
@@ -46,6 +46,9 @@ class Log
46
46
  @tag = parts[2]
47
47
  end
48
48
  end
49
+ if @tag.nil? && autotag
50
+ @tag = File.basename(path)
51
+ end
49
52
  @file = File.open(path)
50
53
  @finished = false
51
54
  buffer
@@ -79,12 +82,8 @@ class Log
79
82
  elsif current =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\d[+-]\d\d\d\d/
80
83
  current[0...28] = "[#{timestamp.to_s}]"
81
84
  end
82
- current
83
- end
84
-
85
- def append(current, timestamp=nil)
86
85
  current.prepend("[#{@tag}]") if @tag && timestamp
87
- @line.push(current)
86
+ current
88
87
  end
89
88
 
90
89
  def buffer
@@ -102,7 +101,7 @@ class Log
102
101
  # puts "current: #{current}"
103
102
  @timestamp = parseTimestamp(current)
104
103
  # puts "timestamp: #{@timestamp}"
105
- append(current, @timestamp)
104
+ @line.push(current)
106
105
  timestamp_index = timestamp_index + 1 if @timestamp.nil?
107
106
  end
108
107
 
@@ -115,7 +114,7 @@ class Log
115
114
  next_timestamp = parseTimestamp(current)
116
115
  # puts "next_timestamp: #{next_timestamp}"
117
116
  file.unreadline(current + "\n") && break unless next_timestamp.nil?
118
- append(current)
117
+ @line.push(current)
119
118
  end
120
119
  rescue EOFError
121
120
  @finished = true if @line.empty?
@@ -130,8 +129,8 @@ end
130
129
 
131
130
  class LogMerge
132
131
  attr_reader :logs, :startTime, :endTime
133
- def initialize(files, startTime=Time.at(0), endTime=Time.at(2000000000000))
134
- @logs = files.map {|f| Log.new(f)}
132
+ def initialize(files, startTime=Time.at(0), endTime=Time.at(2000000000000), autotag=false)
133
+ @logs = files.map {|f| Log.new(f, autotag)}
135
134
  @startTime = DateTime.parse(startTime.to_s)
136
135
  @endTime = DateTime.parse(endTime.to_s)
137
136
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vertenten