multilog-collector 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.2)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+ rcov (0.9.9)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.5.2)
19
+ rcov
20
+ shoulda
data/README.rdoc CHANGED
@@ -11,7 +11,8 @@ This is a log collector for multilog of daemontools services.
11
11
  Usage: multilog-collector [options]
12
12
  --help show this message
13
13
  -d, --directory=DIR service directory default: /service
14
-
14
+ -l, --lines=N lines to collect default: 100
15
+
15
16
  == Contributing to multilog-collector
16
17
 
17
18
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.3
@@ -1,2 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
- require __FILE__ + '.rb'
2
+ require 'optparse'
3
+
4
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
5
+ require 'djb/daemontools/multilog/collector'
6
+
7
+ directory = "/service"
8
+ collector = Djb::Daemontools::Multilog::Collector.new
9
+
10
+ opt = OptionParser.new
11
+ opt.on('--help', 'show this message') { puts opt; exit }
12
+ opt.on('-d DIR','--directory=DIR','service directory default: /service'){ |v| collector.directory = v }
13
+ opt.on('-l N','--lines=N','lines to collect default: 100'){ |v| collector.lines = v.to_i }
14
+ opt.parse!(ARGV)
15
+
16
+ puts collector.collect
17
+
@@ -6,7 +6,8 @@ module Djb
6
6
  module Multilog
7
7
  class Collector
8
8
  attr_accessor :service_dir,:lines
9
- alias directory= service_dir=
9
+ alias :directory :service_dir
10
+ alias :directory= :service_dir=
10
11
 
11
12
  def initialize(dir = "/service")
12
13
  @lines = 100
@@ -23,7 +24,8 @@ module Djb
23
24
  a.time <=> b.time
24
25
  end
25
26
  # all[all.length - @lines..-1]
26
- all[-@lines..-1]
27
+ lines = [@lines,all.length].min
28
+ all[-lines..-1]
27
29
  end
28
30
  end
29
31
 
@@ -5,9 +5,11 @@ module Djb
5
5
  module Daemontools
6
6
  module Multilog
7
7
  class Log
8
+ attr_accessor :time
8
9
 
9
10
  def initialize(line,service)
10
11
  @line = line
12
+ @time = to_time
11
13
  @service = service
12
14
  end
13
15
 
@@ -15,7 +17,7 @@ module Djb
15
17
  return $1 if /^(@[a-z0-9]+) / =~ @line
16
18
  end
17
19
 
18
- def time
20
+ def to_time
19
21
  Tai64n::to_local(tai64n)
20
22
  end
21
23
 
@@ -10,7 +10,7 @@ module Djb
10
10
  @file = file
11
11
  open(file) do |f|
12
12
  while line = f.gets
13
- self << Log.new(line,service)
13
+ self << Log.new(line,service) rescue {}
14
14
  end
15
15
  end
16
16
  self
data/lib/djb/tai64n.rb CHANGED
@@ -5,7 +5,7 @@ module Djb
5
5
  # Thanks.
6
6
  # http://d.hatena.ne.jp/unageanu/20091207
7
7
  def self.to_local tai
8
- raise "illegal format" unless tai =~ /\@40000000([\da-f]{8})([\da-f]{8})/
8
+ raise "illegal format: #{tai}" unless tai =~ /\@40000000([\da-f]{8})([\da-f]{8})/
9
9
  Time.at($1.hex-10, $2.hex/1000.0)
10
10
  end
11
11
  end
@@ -5,26 +5,27 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{multilog-collector}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yoshihiro TAKAHARA"]
12
- s.date = %q{2011-01-16}
12
+ s.date = %q{2011-01-27}
13
+ s.default_executable = %q{multilog-collector}
13
14
  s.description = %q{This is a log collector for multilog of daemontools services.}
14
15
  s.email = %q{y.takahara@gmail.com}
15
- s.executables = ["multilog-collector.rb", "multilog-collector"]
16
+ s.executables = ["multilog-collector"]
16
17
  s.extra_rdoc_files = [
17
18
  "LICENSE.txt",
18
19
  "README.rdoc"
19
20
  ]
20
21
  s.files = [
21
22
  "Gemfile",
23
+ "Gemfile.lock",
22
24
  "LICENSE.txt",
23
25
  "README.rdoc",
24
26
  "Rakefile",
25
27
  "VERSION",
26
28
  "bin/multilog-collector",
27
- "bin/multilog-collector.rb",
28
29
  "lib/djb/daemontools/multilog/collector.rb",
29
30
  "lib/djb/daemontools/multilog/log.rb",
30
31
  "lib/djb/daemontools/multilog/logs.rb",
@@ -37,7 +38,7 @@ Gem::Specification.new do |s|
37
38
  s.homepage = %q{http://github.com/tumf/multilog-collector}
38
39
  s.licenses = ["MIT"]
39
40
  s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.4.1}
41
+ s.rubygems_version = %q{1.3.7}
41
42
  s.summary = %q{log collector for multilog.}
42
43
  s.test_files = [
43
44
  "test/helper.rb",
@@ -45,6 +46,7 @@ Gem::Specification.new do |s|
45
46
  ]
46
47
 
47
48
  if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
50
  s.specification_version = 3
49
51
 
50
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multilog-collector
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
4
+ hash: 21
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoshihiro TAKAHARA
@@ -15,10 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-16 00:00:00 +09:00
19
- default_executable:
18
+ date: 2011-01-27 00:00:00 +09:00
19
+ default_executable: multilog-collector
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ prerelease: false
24
+ name: shoulda
22
25
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
26
  none: false
24
27
  requirements:
@@ -29,10 +32,10 @@ dependencies:
29
32
  - 0
30
33
  version: "0"
31
34
  requirement: *id001
32
- prerelease: false
33
- name: shoulda
34
- type: :development
35
35
  - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ prerelease: false
38
+ name: bundler
36
39
  version_requirements: &id002 !ruby/object:Gem::Requirement
37
40
  none: false
38
41
  requirements:
@@ -45,10 +48,10 @@ dependencies:
45
48
  - 0
46
49
  version: 1.0.0
47
50
  requirement: *id002
48
- prerelease: false
49
- name: bundler
50
- type: :development
51
51
  - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ prerelease: false
54
+ name: jeweler
52
55
  version_requirements: &id003 !ruby/object:Gem::Requirement
53
56
  none: false
54
57
  requirements:
@@ -61,10 +64,10 @@ dependencies:
61
64
  - 2
62
65
  version: 1.5.2
63
66
  requirement: *id003
64
- prerelease: false
65
- name: jeweler
66
- type: :development
67
67
  - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ prerelease: false
70
+ name: rcov
68
71
  version_requirements: &id004 !ruby/object:Gem::Requirement
69
72
  none: false
70
73
  requirements:
@@ -75,13 +78,9 @@ dependencies:
75
78
  - 0
76
79
  version: "0"
77
80
  requirement: *id004
78
- prerelease: false
79
- name: rcov
80
- type: :development
81
81
  description: This is a log collector for multilog of daemontools services.
82
82
  email: y.takahara@gmail.com
83
83
  executables:
84
- - multilog-collector.rb
85
84
  - multilog-collector
86
85
  extensions: []
87
86
 
@@ -90,12 +89,12 @@ extra_rdoc_files:
90
89
  - README.rdoc
91
90
  files:
92
91
  - Gemfile
92
+ - Gemfile.lock
93
93
  - LICENSE.txt
94
94
  - README.rdoc
95
95
  - Rakefile
96
96
  - VERSION
97
97
  - bin/multilog-collector
98
- - bin/multilog-collector.rb
99
98
  - lib/djb/daemontools/multilog/collector.rb
100
99
  - lib/djb/daemontools/multilog/log.rb
101
100
  - lib/djb/daemontools/multilog/logs.rb
@@ -134,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
133
  requirements: []
135
134
 
136
135
  rubyforge_project:
137
- rubygems_version: 1.4.1
136
+ rubygems_version: 1.3.7
138
137
  signing_key:
139
138
  specification_version: 3
140
139
  summary: log collector for multilog.
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'optparse'
3
-
4
- $:.unshift(File.dirname(__FILE__) + '/../lib')
5
- require 'djb/daemontools/multilog/collector'
6
-
7
- directory = "/service"
8
- collector = Djb::Daemontools::Multilog::Collector.new
9
-
10
- opt = OptionParser.new
11
- opt.on('--help', 'show this message') { puts opt; exit }
12
- opt.on('-d DIR','--directory=DIR','service directory default: /service'){ |v| collector.directory = v }
13
- opt.on('-l N','--lines=N','lines to collect default: 100'){ |v| collector.lines = v.to_i }
14
- opt.parse!(ARGV)
15
-
16
- puts collector.collect
17
-