analogger 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +60 -0
- data/README +19 -0
- data/analogger.gemspec +41 -0
- data/bin/analogger +94 -0
- data/external/package.rb +672 -0
- data/external/test_support.rb +58 -0
- data/setup.rb +26 -0
- data/src/swiftcore/Analogger.rb +293 -0
- data/src/swiftcore/Analogger/Client.rb +103 -0
- data/test/TC_Analogger.rb +151 -0
- data/test/analogger.cnf +22 -0
- data/test/analogger2.cnf +9 -0
- data/test/tc_template.rb +15 -0
- metadata +78 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rbconfig'
|
3
|
+
require 'logger'
|
4
|
+
require 'external/test_support'
|
5
|
+
SwiftcoreTestSupport.set_src_dir
|
6
|
+
require 'swiftcore/Analogger/Client'
|
7
|
+
|
8
|
+
class TC_Analogger < Test::Unit::TestCase
|
9
|
+
|
10
|
+
@@testdir = SwiftcoreTestSupport.test_dir(__FILE__)
|
11
|
+
|
12
|
+
def setup
|
13
|
+
assert_nothing_raised("setup failed") do
|
14
|
+
Dir.chdir(@@testdir)
|
15
|
+
SwiftcoreTestSupport.announce(:analogger,"Analogger Tests")
|
16
|
+
|
17
|
+
@rubybin = File.join(::Config::CONFIG['bindir'],::Config::CONFIG['ruby_install_name'])
|
18
|
+
@rubybin << ::Config::CONFIG['EXEEXT']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_analogger
|
23
|
+
@analogger_pid = SwiftcoreTestSupport::create_process(:dir => '.',:cmd => ["#{@rubybin} ../bin/analogger -c analogger.cnf"])
|
24
|
+
sleep 1
|
25
|
+
logger = nil
|
26
|
+
|
27
|
+
pid = File.read('log/analogger.pid').chomp
|
28
|
+
|
29
|
+
assert_equal(@analogger_pid.to_s,pid)
|
30
|
+
|
31
|
+
puts "Delivering test messages."
|
32
|
+
|
33
|
+
levels = ['debug','info','warn']
|
34
|
+
|
35
|
+
assert_nothing_raised { logger = Swiftcore::Analogger::Client.new('idontmatch','127.0.0.1','47990') }
|
36
|
+
|
37
|
+
levels.each do |level|
|
38
|
+
assert_nothing_raised { logger.log(level,'abc123') }
|
39
|
+
end
|
40
|
+
|
41
|
+
levels = ['a','b','c']
|
42
|
+
|
43
|
+
assert_nothing_raised { logger = Swiftcore::Analogger::Client.new('a','127.0.0.1','47990') }
|
44
|
+
|
45
|
+
levels.each do |level|
|
46
|
+
assert_nothing_raised { logger.log(level,'abc123') }
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_nothing_raised { logger = Swiftcore::Analogger::Client.new('b','127.0.0.1','47990') }
|
50
|
+
|
51
|
+
levels.each do |level|
|
52
|
+
assert_nothing_raised { logger.log(level,'abc123') }
|
53
|
+
end
|
54
|
+
|
55
|
+
levels = ['info','warn','fatal']
|
56
|
+
|
57
|
+
assert_nothing_raised { logger = Swiftcore::Analogger::Client.new('c','127.0.0.1','47990') }
|
58
|
+
|
59
|
+
levels.each do |level|
|
60
|
+
assert_nothing_raised { logger.log(level,'abc123') }
|
61
|
+
end
|
62
|
+
|
63
|
+
levels = ['info','junk']
|
64
|
+
|
65
|
+
assert_nothing_raised { logger = Swiftcore::Analogger::Client.new('d','127.0.0.1','47990') }
|
66
|
+
|
67
|
+
levels.each do |level|
|
68
|
+
assert_nothing_raised { logger.log(level,'abc123') }
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_nothing_raised { logger = Swiftcore::Analogger::Client.new('stderr','127.0.0.1','47990') }
|
72
|
+
|
73
|
+
5.times {|x| assert_nothing_raised { logger.log('info',"Logging to STDERR ##{x}") }}
|
74
|
+
|
75
|
+
puts "Waiting for log sync.\n\n"
|
76
|
+
sleep 2
|
77
|
+
|
78
|
+
puts "\nChecking results.\n\n"
|
79
|
+
logfile = ''
|
80
|
+
assert_nothing_raised { logfile = File.read('log/default.log') }
|
81
|
+
assert(logfile =~ /idontmatch|debug|abc123/,"Default log doesn't appear to have the expected message: idontmatch|debug|abc123")
|
82
|
+
assert(logfile =~ /idontmatch|debug|Last message repeated 2 times/,"Default log doesn't appear to have the expected message: idontmatch|debug|Last message repeated 2 times")
|
83
|
+
|
84
|
+
logfile = ''
|
85
|
+
assert_nothing_raised { logfile = File.read('log/a.log') }
|
86
|
+
assert(logfile =~ /a|a|abc123/,"Log doesn't appear to have the expected message: a|a|abc123")
|
87
|
+
assert(logfile =~ /a|b|abc123/,"Log doesn't appear to have the expected message: a|b|abc123")
|
88
|
+
assert(logfile =~ /a|c|abc123/,"Log doesn't appear to have the expected message: a|c|abc123")
|
89
|
+
assert(logfile =~ /b|a|abc123/,"Log doesn't appear to have the expected message: b|a|abc123")
|
90
|
+
assert(logfile =~ /b|b|abc123/,"Log doesn't appear to have the expected message: b|b|abc123")
|
91
|
+
assert(logfile =~ /b|c|abc123/,"Log doesn't appear to have the expected message: b|c|abc123")
|
92
|
+
|
93
|
+
logfile = ''
|
94
|
+
assert_nothing_raised { logfile = File.read('log/c.log') }
|
95
|
+
assert(logfile =~ /c|info|abc123/,"Log doesn't appear to have the expected message: c|info|abc123")
|
96
|
+
assert(logfile =~ /c|warn|abc123/,"Log doesn't appear to have the expected message: c|warn|abc123")
|
97
|
+
assert(logfile =~ /c|fatal|abc123/,"Log doesn't appear to have the expected message: c|fatal|abc123")
|
98
|
+
|
99
|
+
logfile = ''
|
100
|
+
assert_nothing_raised { logfile = File.read('log/d.log') }
|
101
|
+
assert(logfile =~ /d|info|abc123/,"Log doesn't appear to have the expected message: d|info|abc123")
|
102
|
+
assert(logfile !~ /junk/,"Log file has a message in it that should have been dropped.")
|
103
|
+
teardown
|
104
|
+
|
105
|
+
require 'benchmark'
|
106
|
+
|
107
|
+
speedtest('short messages','0123456789')
|
108
|
+
speedtest('larger messages','0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789')
|
109
|
+
logger_speedtest('short messages','0123456789')
|
110
|
+
logger_speedtest('larger messages','0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789')
|
111
|
+
end
|
112
|
+
|
113
|
+
def speedtest(label,message)
|
114
|
+
puts "Analogger Speedtest -- #{label}"
|
115
|
+
@analogger_pid = SwiftcoreTestSupport::create_process(:dir => '.',:cmd => ["#{@rubybin} ../bin/analogger -c analogger2.cnf"])
|
116
|
+
logger = nil
|
117
|
+
assert_nothing_raised { logger = Swiftcore::Analogger::Client.new('speed','127.0.0.1','47990') }
|
118
|
+
lvl = 'info'
|
119
|
+
puts "Testing 100000 messages of #{message.length} bytes each."
|
120
|
+
start = total = nil
|
121
|
+
Benchmark.bm do |bm|
|
122
|
+
bm.report { start = Time.now; 100000.times { logger.log(lvl,message) }; total = Time.now - start}
|
123
|
+
end
|
124
|
+
total = Time.now - start
|
125
|
+
rate = 100000 / total
|
126
|
+
puts "\nMessage rate: #{rate}/second (#{total})\n\n"
|
127
|
+
teardown
|
128
|
+
end
|
129
|
+
|
130
|
+
def logger_speedtest(label,message)
|
131
|
+
puts "Ruby Logger Speedtest -- #{label}"
|
132
|
+
puts "Testing 100000 messages of #{message.length} bytes each."
|
133
|
+
logger = Logger.new('log/ra')
|
134
|
+
start = total = nil
|
135
|
+
Benchmark.bm do |bm|
|
136
|
+
bm.report { start = Time.now; 100000.times { logger.info(message) }; total = Time.now - start}
|
137
|
+
end
|
138
|
+
rate = 100000 / total
|
139
|
+
puts "\nMessage rate: #{rate}/second (#{total})\n\n"
|
140
|
+
logger.close
|
141
|
+
File.delete('log/ra')
|
142
|
+
end
|
143
|
+
|
144
|
+
def teardown
|
145
|
+
Process.kill "SIGTERM",@analogger_pid
|
146
|
+
Process.wait @analogger_pid
|
147
|
+
Dir['log/*'].each {|fn| File.delete(fn)}
|
148
|
+
rescue
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
data/test/analogger.cnf
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
port: 47990
|
2
|
+
host: 127.0.0.1
|
3
|
+
default_log: log/default.log
|
4
|
+
daemonize: false
|
5
|
+
syncinterval: 1
|
6
|
+
pidfile: log/analogger.pid
|
7
|
+
logs:
|
8
|
+
- service:
|
9
|
+
- a
|
10
|
+
- b
|
11
|
+
logfile: log/a.log
|
12
|
+
cull: true
|
13
|
+
levels: a,b,c,d
|
14
|
+
- service: c
|
15
|
+
logfile: log/c.log
|
16
|
+
cull: true
|
17
|
+
- service: d
|
18
|
+
logfile: log/d.log
|
19
|
+
cull: false
|
20
|
+
- service: stderr
|
21
|
+
logfile: STDERR
|
22
|
+
cull: true
|
data/test/analogger2.cnf
ADDED
data/test/tc_template.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: analogger
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2007-03-31 00:00:00 +02:00
|
8
|
+
summary: A fast asynchronous logging service and client for Ruby.
|
9
|
+
require_paths:
|
10
|
+
- src
|
11
|
+
email: wyhaines@gmail.com
|
12
|
+
homepage: http://analogger.swiftcore.org/
|
13
|
+
rubyforge_project: analogger
|
14
|
+
description: ""
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Kirk Haines
|
31
|
+
files:
|
32
|
+
- bin
|
33
|
+
- external
|
34
|
+
- src
|
35
|
+
- test
|
36
|
+
- doc
|
37
|
+
- setup.rb
|
38
|
+
- INSTALL
|
39
|
+
- README
|
40
|
+
- analogger.gemspec
|
41
|
+
- bin/analogger
|
42
|
+
- external/test_support.rb
|
43
|
+
- external/package.rb
|
44
|
+
- src/swiftcore
|
45
|
+
- src/swiftcore/Analogger
|
46
|
+
- src/swiftcore/Analogger.rb
|
47
|
+
- src/swiftcore/Analogger/Client.rb
|
48
|
+
- test/log
|
49
|
+
- test/TC_Analogger.rb
|
50
|
+
- test/tc_template.rb
|
51
|
+
- test/analogger.cnf
|
52
|
+
- test/analogger2.cnf
|
53
|
+
test_files:
|
54
|
+
- test/TC_Analogger.rb
|
55
|
+
rdoc_options:
|
56
|
+
- --title
|
57
|
+
- Swiftcore::Analogger
|
58
|
+
- --main
|
59
|
+
- README
|
60
|
+
- --line-numbers
|
61
|
+
extra_rdoc_files:
|
62
|
+
- README
|
63
|
+
executables:
|
64
|
+
- analogger
|
65
|
+
extensions: []
|
66
|
+
|
67
|
+
requirements:
|
68
|
+
- Eventmachine 0.7.0 or higher.
|
69
|
+
dependencies:
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: eventmachine
|
72
|
+
version_requirement:
|
73
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.0.0
|
78
|
+
version:
|