analogger 0.5.0 → 0.9.1
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 +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +24 -0
- data/INSTALL +1 -1
- data/Rakefile +11 -0
- data/analogger.gemspec +37 -35
- data/bin/analogger +66 -60
- data/external/package.rb +12 -11
- data/external/test_support.rb +3 -6
- data/lib/swiftcore/Analogger.rb +308 -0
- data/{src/swiftcore/Analogger.rb → lib/swiftcore/Analogger.rb.orig} +64 -66
- data/lib/swiftcore/Analogger/AnaloggerProtocol.rb +78 -0
- data/lib/swiftcore/Analogger/Client.rb +406 -0
- data/lib/swiftcore/Analogger/EMClient.rb +100 -0
- data/lib/swiftcore/Analogger/version.rb +5 -0
- data/lib/swiftcore/LoggerInterface.rb +316 -0
- data/setup.rb +11 -10
- metadata +117 -70
- data/src/swiftcore/Analogger/Client.rb +0 -103
- data/test/TC_Analogger.rb +0 -151
- data/test/analogger.cnf +0 -22
- data/test/analogger2.cnf +0 -9
- data/test/tc_template.rb +0 -15
metadata
CHANGED
@@ -1,78 +1,125 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
1
|
+
--- !ruby/object:Gem::Specification
|
4
2
|
name: analogger
|
5
|
-
version: !ruby/object:Gem::Version
|
6
|
-
version: 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:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
25
5
|
platform: ruby
|
26
|
-
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
|
-
authors:
|
6
|
+
authors:
|
30
7
|
- Kirk Haines
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
-
|
35
|
-
|
36
|
-
-
|
37
|
-
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: eventmachine
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.2'
|
69
|
+
description: Analogger provides a fast and very stable asynchronous central logging
|
70
|
+
service capable of handling heavy logging loads. It has been in production use for
|
71
|
+
almost a decade.
|
72
|
+
email:
|
73
|
+
- wyhaines@gmail.com
|
74
|
+
executables:
|
75
|
+
- analogger
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
38
81
|
- INSTALL
|
39
82
|
- README
|
83
|
+
- Rakefile
|
40
84
|
- analogger.gemspec
|
41
85
|
- bin/analogger
|
42
|
-
- external/test_support.rb
|
43
86
|
- external/package.rb
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
requirements:
|
68
|
-
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
87
|
+
- external/test_support.rb
|
88
|
+
- lib/swiftcore/Analogger.rb
|
89
|
+
- lib/swiftcore/Analogger.rb.orig
|
90
|
+
- lib/swiftcore/Analogger/AnaloggerProtocol.rb
|
91
|
+
- lib/swiftcore/Analogger/Client.rb
|
92
|
+
- lib/swiftcore/Analogger/EMClient.rb
|
93
|
+
- lib/swiftcore/Analogger/version.rb
|
94
|
+
- lib/swiftcore/LoggerInterface.rb
|
95
|
+
- setup.rb
|
96
|
+
homepage: https://github.com/wyhaines/analogger
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata:
|
100
|
+
bug_tracker_uri: https://github.com/wyhaines/analogger/issues
|
101
|
+
documentation_uri: https://github.com/wyhaines/analogger
|
102
|
+
homepage_uri: https://github.com/wyhaines/analogger
|
103
|
+
source_code_uri: https://github.com/wyhaines/analogger
|
104
|
+
allowed_push_host: https://rubygems.org
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.7.3
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Analogger is a fast, stable, simple central asynchronous logging service/client.
|
125
|
+
test_files: []
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
include Socket::Constants
|
3
|
-
|
4
|
-
module Swiftcore
|
5
|
-
module Analogger
|
6
|
-
|
7
|
-
# Swift::Analogger::Client is the client library for writing logging
|
8
|
-
# messages to the Swift Analogger asynchronous logging server.
|
9
|
-
#
|
10
|
-
# To use the Analogger client, instantiate an instance of the Client
|
11
|
-
# class.
|
12
|
-
#
|
13
|
-
# logger = Swift::Analogger::Client.new(:myapplog,'127.0.0.1',12345)
|
14
|
-
#
|
15
|
-
# Four arguments are accepted when a new Client is created. The first
|
16
|
-
# is the name of the logging facility that this Client will write to.
|
17
|
-
# The second is the hostname where the Analogger process is running,
|
18
|
-
# and the third is the port number that it is listening on for
|
19
|
-
# connections.
|
20
|
-
#
|
21
|
-
# The fourth argument is optional. Analogger can require an
|
22
|
-
# authentication key before it will allow logging clients to use its
|
23
|
-
# facilities. If the Analogger that one is connecting to requires
|
24
|
-
# an authentication key, it must be passed to the new() call as the
|
25
|
-
# fourth argument. If the key is incorrect, the connection will be
|
26
|
-
# closed.
|
27
|
-
#
|
28
|
-
# If a Client connects to the Analogger using a facility that is
|
29
|
-
# undefined in the Analogger, the log messages will still be accepted,
|
30
|
-
# but they will be dumped to the default logging destination.
|
31
|
-
#
|
32
|
-
# Once connected, the Client is ready to deliver messages to the
|
33
|
-
# Analogger. To send a messagine, the log() method is used:
|
34
|
-
#
|
35
|
-
# logger.log(:debug,"The logging client is now connected.")
|
36
|
-
#
|
37
|
-
# The log() method takes two arguments. The first is the severity of
|
38
|
-
# the message, and the second is the message itself. The default
|
39
|
-
# Analogger severity levels are the same as in the standard Ruby
|
40
|
-
#
|
41
|
-
class Client
|
42
|
-
Cauthentication = 'authentication'.freeze
|
43
|
-
Ci = 'i'.freeze
|
44
|
-
|
45
|
-
def initialize(service = 'default', host = '127.0.0.1' , port = 6766, key = nil)
|
46
|
-
@service = service.to_s
|
47
|
-
@key = key
|
48
|
-
@host = host
|
49
|
-
@port = port
|
50
|
-
connect(host,port)
|
51
|
-
end
|
52
|
-
|
53
|
-
def connect(host,port)
|
54
|
-
tries ||= 0
|
55
|
-
@socket = Socket.new(AF_INET,SOCK_STREAM,0)
|
56
|
-
sockaddr = Socket.pack_sockaddr_in(port,host)
|
57
|
-
@socket.connect(sockaddr)
|
58
|
-
log(Cauthentication,"#{@key}")
|
59
|
-
rescue Exception => e
|
60
|
-
if tries < 3
|
61
|
-
tries += 1
|
62
|
-
@socket.close unless @socket.closed?
|
63
|
-
@socket = nil
|
64
|
-
select(nil,nil,nil,tries * 0.2) if tries > 0
|
65
|
-
retry
|
66
|
-
else
|
67
|
-
raise e
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def reconnect
|
72
|
-
connect(@host,@port)
|
73
|
-
end
|
74
|
-
|
75
|
-
def log(severity,msg)
|
76
|
-
tries ||= 0
|
77
|
-
fullmsg = ":#{@service}:#{severity}:#{msg}"
|
78
|
-
len = [fullmsg.length].pack(Ci)
|
79
|
-
@socket.write "#{len}#{len}#{fullmsg}"
|
80
|
-
rescue Exception => e
|
81
|
-
if tries < 3
|
82
|
-
tries += 1
|
83
|
-
@socket.close unless @socket.closed?
|
84
|
-
@socket = nil
|
85
|
-
select(nil,nil,nil,tries) if tries > 0
|
86
|
-
reconnect
|
87
|
-
retry
|
88
|
-
else
|
89
|
-
raise e
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def close
|
94
|
-
@socket.close
|
95
|
-
end
|
96
|
-
|
97
|
-
def closed?
|
98
|
-
@socket.closed?
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
data/test/TC_Analogger.rb
DELETED
@@ -1,151 +0,0 @@
|
|
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
|