logspray 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +12 -0
- data/LICENSE +22 -0
- data/README.md +12 -0
- data/TODO +1 -0
- data/bin/logspray +40 -0
- data/bin/logspray_file_persister +85 -0
- data/logspray.gemspec +41 -0
- metadata +136 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
License Information:
|
2
|
+
|
3
|
+
Copyright (c) 2010 David Andersen | github.com/davidx | davidx at gmail.com
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# AMQP message bus based logger.
|
2
|
+
|
3
|
+
Put the following in your apache config:
|
4
|
+
|
5
|
+
CustomLog "|logspray --host=myamqploghost --queue=apache_access_log" combined
|
6
|
+
ErrorLog "|logspray --host=myamqploghost --queue=apache_error_log"
|
7
|
+
|
8
|
+
|
9
|
+
on your logserver, add this cronjob:
|
10
|
+
|
11
|
+
* * * * * logspray_file_persister --host=myamqploghost --queue=apache_access_log
|
12
|
+
* * * * * logspray_file_persister --host=myamqploghost --queue=apache_error_log
|
data/TODO
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
- create daemonized queue listener or exchange binding for consumption
|
data/bin/logspray
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'carrot'
|
5
|
+
require 'choice'
|
6
|
+
|
7
|
+
Choice.options do
|
8
|
+
header ''
|
9
|
+
header 'Specific options:'
|
10
|
+
|
11
|
+
option :host, :required =>true do
|
12
|
+
short '-h'
|
13
|
+
long '--host=HOST'
|
14
|
+
desc 'The hostname or ip of the amqp server (required)'
|
15
|
+
default '10.10.10.100'
|
16
|
+
end
|
17
|
+
|
18
|
+
option :queue,:required =>true do
|
19
|
+
short '-q'
|
20
|
+
long '--queue=QUEUE'
|
21
|
+
desc 'The queue'
|
22
|
+
end
|
23
|
+
|
24
|
+
separator ''
|
25
|
+
separator 'Common options: '
|
26
|
+
|
27
|
+
option :help do
|
28
|
+
long '--help'
|
29
|
+
desc 'Show this message'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
HOST = Choice.choices[:host]
|
34
|
+
QUEUE = Choice.choices[:queue]
|
35
|
+
|
36
|
+
client = Carrot.new(:host => HOST)
|
37
|
+
q = client.queue(QUEUE)
|
38
|
+
while (line = $stdin.gets) do
|
39
|
+
q.publish(line)
|
40
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
Copyright (c) 2010 David Andersen | davidx.org | davidx at gmail.com
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
23
|
+
=end
|
24
|
+
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'carrot'
|
28
|
+
require 'choice'
|
29
|
+
require 'date'
|
30
|
+
require 'fileutils'
|
31
|
+
|
32
|
+
Choice.options do
|
33
|
+
header ''
|
34
|
+
header 'Specific options:'
|
35
|
+
|
36
|
+
option :host, :required => true do
|
37
|
+
short '-host'
|
38
|
+
long '--host=HOST'
|
39
|
+
desc 'The hostname or ip of the amqp server (required)'
|
40
|
+
end
|
41
|
+
|
42
|
+
option :queue, :required => true do
|
43
|
+
short '-q'
|
44
|
+
long '--queue=QUEUE'
|
45
|
+
desc 'The queue'
|
46
|
+
end
|
47
|
+
option :logfile, :required => true do
|
48
|
+
short '-f'
|
49
|
+
long '--logfile=LOGFILE'
|
50
|
+
desc 'The logfile to output to'
|
51
|
+
end
|
52
|
+
option :logdir do
|
53
|
+
short '-d'
|
54
|
+
long '--logdir=LOGDIR'
|
55
|
+
desc 'The logdir to use'
|
56
|
+
default '/var/log/logspray'
|
57
|
+
end
|
58
|
+
separator ''
|
59
|
+
separator 'Common options: '
|
60
|
+
|
61
|
+
option :help do
|
62
|
+
long '--help'
|
63
|
+
desc 'Show this message'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
DATE=DateTime.now.strftime("%Y%m%d")
|
68
|
+
HOST = Choice.choices[:host]
|
69
|
+
QUEUE = Choice.choices[:queue]
|
70
|
+
LOGDIR = Choice.choices[:logdir]
|
71
|
+
LOGFILE = Choice.choices[:logfile] || "#{DEFAULT_LOGDIR}/#{QUEUE}/#{DATE}_#{QUEUE}.log"
|
72
|
+
|
73
|
+
FileUtils.mkdir_p(File.dirname(LOGFILE))
|
74
|
+
|
75
|
+
client = Carrot.new(:host => HOST)
|
76
|
+
q = client.queue(QUEUE)
|
77
|
+
|
78
|
+
file = File.open(LOGFILE, "a")
|
79
|
+
while msg = q.pop(:ack => true)
|
80
|
+
file.syswrite(msg)
|
81
|
+
q.ack
|
82
|
+
end
|
83
|
+
file.close
|
84
|
+
Carrot.stop
|
85
|
+
|
data/logspray.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
3
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
4
|
+
## the sub! line in the Rakefile
|
5
|
+
s.name = 'logspray'
|
6
|
+
s.version = '0.0.1'
|
7
|
+
s.date = '2011-01-28'
|
8
|
+
|
9
|
+
s.summary = "AMQP logger"
|
10
|
+
s.description = "AMQP logger to be used by daemons like apache that support pipe in"
|
11
|
+
s.authors = ["davidx (David Andersen)"]
|
12
|
+
s.email = 'davidx@gmail.com'
|
13
|
+
s.homepage = 'http://github.com/davidx/logspray'
|
14
|
+
|
15
|
+
s.require_paths = %w[lib]
|
16
|
+
|
17
|
+
## This sections is only necessary if you have C extensions.
|
18
|
+
# s.require_paths << 'ext'
|
19
|
+
# s.extensions = %w[ext/extconf.rb]
|
20
|
+
|
21
|
+
## If your gem includes any executables, list them here.
|
22
|
+
s.executables = ["logspray", "logspray_file_persister"]
|
23
|
+
s.default_executable = 'logspray'
|
24
|
+
|
25
|
+
## Specify any RDoc options here. You'll want to add your README and
|
26
|
+
## LICENSE files to the extra_rdoc_files list.
|
27
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
28
|
+
|
29
|
+
## List your runtime dependencies here. Runtime dependencies are those
|
30
|
+
## that are needed for an end user to actually USE your code.
|
31
|
+
s.add_dependency('carrot')
|
32
|
+
s.add_dependency('choice')
|
33
|
+
## List your development dependencies here. Development dependencies are
|
34
|
+
## those that are only needed during development
|
35
|
+
s.add_development_dependency('rake')
|
36
|
+
s.add_development_dependency('dust')
|
37
|
+
s.add_development_dependency('shindo')
|
38
|
+
|
39
|
+
s.files = `git ls-files`.split("\n")
|
40
|
+
s.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logspray
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- davidx (David Andersen)
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-28 00:00:00 -08:00
|
18
|
+
default_executable: logspray
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: carrot
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: choice
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: dust
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id004
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: shindo
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id005
|
85
|
+
description: AMQP logger to be used by daemons like apache that support pipe in
|
86
|
+
email: davidx@gmail.com
|
87
|
+
executables:
|
88
|
+
- logspray
|
89
|
+
- logspray_file_persister
|
90
|
+
extensions: []
|
91
|
+
|
92
|
+
extra_rdoc_files: []
|
93
|
+
|
94
|
+
files:
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE
|
98
|
+
- README.md
|
99
|
+
- TODO
|
100
|
+
- bin/logspray
|
101
|
+
- bin/logspray_file_persister
|
102
|
+
- logspray.gemspec
|
103
|
+
has_rdoc: true
|
104
|
+
homepage: http://github.com/davidx/logspray
|
105
|
+
licenses: []
|
106
|
+
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options:
|
109
|
+
- --charset=UTF-8
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
version: "0"
|
128
|
+
requirements: []
|
129
|
+
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 1.3.7
|
132
|
+
signing_key:
|
133
|
+
specification_version: 3
|
134
|
+
summary: AMQP logger
|
135
|
+
test_files: []
|
136
|
+
|