yell-adapters-syslogsd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +7 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/yell/adapters/syslogsd.rb +36 -0
- data/lib/yell-adapters-syslogsd.rb +3 -0
- data/logger_test.rb +9 -0
- data/spec/logger_spec.rb +40 -0
- data/yell-adapters-syslogsd.gemspec +25 -0
- metadata +151 -0
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
4
|
+
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Yell::Adapters::Syslogsd
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'yell-adapters-syslogsd'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install yell-adapters-syslogsd
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/yell-adapters-syslogsd/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Yell
|
2
|
+
module Adapters
|
3
|
+
class Syslogsd < Yell::Adapters::Base
|
4
|
+
|
5
|
+
attr_accessor :host, :port, :facility, :prefix
|
6
|
+
|
7
|
+
setup do |opts|
|
8
|
+
@host = opts[:host] || 'localhost'
|
9
|
+
@port = opts[:port] || 514
|
10
|
+
@facility = opts[:facility] || $0
|
11
|
+
@prefix = opts[:prefix] || ''
|
12
|
+
|
13
|
+
@instance = SyslogSD::Logger.new @host, @port
|
14
|
+
end
|
15
|
+
|
16
|
+
def yank_hashes_from *messages
|
17
|
+
messages.select{|m| m.is_a? Hash}.reduce(&:merge) || {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_combined_message *messages
|
21
|
+
messages.select{|m| m.is_a? String}.join(' ') || ""
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_notify_for event, message, data
|
25
|
+
data.merge({:short_message => "#{@prefix}#{message}", :level => event.level, :facility => @facility})
|
26
|
+
end
|
27
|
+
|
28
|
+
write do |event|
|
29
|
+
structured_data = yank_hashes_from(*event.messages)
|
30
|
+
message = get_combined_message(*event.messages)
|
31
|
+
@instance.notify! get_notify_for(event, message, structured_data)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
register :syslogsd, Yell::Adapters::Syslogsd
|
36
|
+
end
|
data/logger_test.rb
ADDED
data/spec/logger_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'yell-adapters-syslogsd'
|
2
|
+
|
3
|
+
class SyslogSD::Notifier
|
4
|
+
attr_reader :_mock_data
|
5
|
+
def notify! *opts
|
6
|
+
$_mock_data = opts
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
describe Yell::Adapters::Syslogsd do
|
12
|
+
before :each do
|
13
|
+
@logger = Yell.new(:syslogsd, {:facility => "rspec"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should handle more than 2 arguments" do
|
17
|
+
@logger.info "Hello", "there", "this", "is", "a", "test", {:struct => true}
|
18
|
+
expect($_mock_data[0][:short_message]).to eq "Hello there this is a test"
|
19
|
+
expect($_mock_data[0][:struct]).to eq true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should handle no arguments" do
|
23
|
+
@logger.info
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should handle multi-line messages" do
|
27
|
+
@logger.info "Test\nAnd another"
|
28
|
+
expect($_mock_data[0][:short_message]).to eq "Test\nAnd another"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "convert input into the format expected by syslog-sd" do
|
32
|
+
@logger.info "Test", {:with_structured => 1}
|
33
|
+
expect($_mock_data).to eq [{:with_structured => 1, :facility => "rspec", :level => 1, :short_message => "Test"}]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should filter out harmful keys" do
|
37
|
+
@logger.debug "Test", {:level => 5, :short_message => "HI"}
|
38
|
+
expect($_mock_data).to eq [{:level => 0, :facility => "rspec", :short_message => "Test"}]
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
#require 'yell/adapters/syslogsd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "yell-adapters-syslogsd"
|
8
|
+
spec.version = '0.0.1' # Yell::Adapters::Syslogsd::VERSION
|
9
|
+
spec.authors = ["Raymond F. Wells"]
|
10
|
+
spec.email = ["rfw2nd@gmail.com"]
|
11
|
+
spec.summary = %q{Connect SyslogSD to Yell}
|
12
|
+
spec.description = %q{Allows one to use syslog-sd with yell. Supports structured data.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "Apache2"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.add_development_dependency 'rspec', '2.14'
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "yell", "~> 2.0.4"
|
24
|
+
spec.add_dependency 'syslog-sd', '~> 1.3.2'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yell-adapters-syslogsd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Raymond F. Wells
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2014-07-07 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 31
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 14
|
32
|
+
version: "2.14"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bundler
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 6
|
47
|
+
version: "1.6"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rake
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: yell
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 7
|
73
|
+
segments:
|
74
|
+
- 2
|
75
|
+
- 0
|
76
|
+
- 4
|
77
|
+
version: 2.0.4
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: syslog-sd
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 31
|
89
|
+
segments:
|
90
|
+
- 1
|
91
|
+
- 3
|
92
|
+
- 2
|
93
|
+
version: 1.3.2
|
94
|
+
type: :runtime
|
95
|
+
version_requirements: *id005
|
96
|
+
description: Allows one to use syslog-sd with yell. Supports structured data.
|
97
|
+
email:
|
98
|
+
- rfw2nd@gmail.com
|
99
|
+
executables: []
|
100
|
+
|
101
|
+
extensions: []
|
102
|
+
|
103
|
+
extra_rdoc_files: []
|
104
|
+
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/yell-adapters-syslogsd.rb
|
112
|
+
- lib/yell/adapters/syslogsd.rb
|
113
|
+
- logger_test.rb
|
114
|
+
- spec/logger_spec.rb
|
115
|
+
- yell-adapters-syslogsd.gemspec
|
116
|
+
homepage: ""
|
117
|
+
licenses:
|
118
|
+
- Apache2
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: 3
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
142
|
+
requirements: []
|
143
|
+
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 1.8.25
|
146
|
+
signing_key:
|
147
|
+
specification_version: 3
|
148
|
+
summary: Connect SyslogSD to Yell
|
149
|
+
test_files:
|
150
|
+
- spec/logger_spec.rb
|
151
|
+
has_rdoc:
|