blabbermouth-syslog 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed592191625c0102beb7d6e3e8de45fb0c626e92
4
+ data.tar.gz: dbd5fb6aedd0e06f370d9f7cb65d4ac97a5fb81d
5
+ SHA512:
6
+ metadata.gz: 43b2b688378e35dd5e07e793964a1af928c529bc883c5ebe0366a392f71ae1b42543089747772bfbc5f47be7ebb05ad67068065121ebbb89fa557b105ff663e1
7
+ data.tar.gz: 1c066da42042d6677d15861c333f51a3c529e997b782d0b613ad482b42da19f466560af14c8301c4e242d895752f454a5ddb9f5e07e2f81701f7bd6df1037e35
@@ -0,0 +1,65 @@
1
+ require 'syslog/logger'
2
+
3
+ module Blabbermouth
4
+ module Bystanders
5
+ class Syslog < Base
6
+ include Blabbermouth::Bystanders::Formatter
7
+ include Blabbermouth::Bystanders::DynamicEvents
8
+
9
+ LOG_LEVELS = [:debug, :error, :fatal, :info, :unknown, :warn]
10
+
11
+ def debug(key, msg=nil, *args)
12
+ relay :debug, key, msg, *args
13
+ end
14
+
15
+ def error(key, e, *args)
16
+ relay :error, key, e, *args
17
+ end
18
+
19
+ def fatal(key, e, *args)
20
+ relay :fatal, key, e, *args
21
+ end
22
+
23
+ def info(key, msg=nil, *args)
24
+ relay :info, key, msg, *args
25
+ end
26
+
27
+ def unknown(key, msg=nil, *args)
28
+ relay :unknown, key, msg, *args
29
+ end
30
+
31
+ def warn(key, msg=nil, *args)
32
+ relay :warn, key, msg, *args
33
+ end
34
+
35
+ def time(key, duration, *args)
36
+ relay :time, key, duration, *args
37
+ end
38
+
39
+ def count(key, total, *args)
40
+ relay :count, key, total, *args
41
+ end
42
+
43
+ def increment(key, by=1, *args)
44
+ relay :increment, key, by, *args
45
+ end
46
+
47
+ def relay(meth, key, *args)
48
+ data, opts, args = parse_args(*args)
49
+ log meth, key, args.first, data
50
+ end
51
+
52
+ protected
53
+
54
+ def syslog
55
+ @syslog ||= Syslog::Logger.new 'blabbermouth'
56
+ end
57
+
58
+ def log(event, key, msg, data={})
59
+ level = (LOG_LEVELS.include?(event)) ? event : :info
60
+ syslog.send(level, log_message(event, key, msg, data))
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,6 @@
1
+ require 'blabbermouth/version'
2
+ module Blabbermouth
3
+ module Syslog
4
+ VERSION = Blabbermouth::VERSION
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ require 'blabbermouth'
2
+ module Blabbermouth
3
+ module Syslog
4
+ end
5
+ end
6
+ require 'blabbermouth/syslog/version'
7
+ require 'blabbermouth/syslog/bystander'
@@ -0,0 +1,78 @@
1
+ require 'blabbermouth-syslog'
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Blabbermouth::Bystanders::Syslog do
5
+ let(:syslog) { subject.send(:syslog) }
6
+
7
+ describe '#debug' do
8
+ it 'posts to syslog' do
9
+ expect(syslog).to receive(:debug)
10
+ subject.debug('test.debug', 'test')
11
+ end
12
+ end
13
+
14
+ describe '#error' do
15
+ it 'posts to syslog' do
16
+ expect(syslog).to receive(:error)
17
+ subject.error('test.error', StandardError.new)
18
+ end
19
+ end
20
+
21
+ describe '#fatal' do
22
+ it 'posts to syslog' do
23
+ expect(syslog).to receive(:fatal)
24
+ subject.fatal('test.fatal', Exception.new)
25
+ end
26
+ end
27
+
28
+ describe '#info' do
29
+ it 'posts to syslog' do
30
+ expect(syslog).to receive(:info)
31
+ subject.info('test.info', 'test')
32
+ end
33
+ end
34
+
35
+ describe '#info' do
36
+ it 'posts to syslog' do
37
+ expect(syslog).to receive(:unknown)
38
+ subject.unknown('test.unknown', 'test')
39
+ end
40
+ end
41
+
42
+ describe '#warn' do
43
+ it 'posts to syslog' do
44
+ expect(syslog).to receive(:warn)
45
+ subject.warn('test.warn', 'test')
46
+ end
47
+ end
48
+
49
+ describe '#increment' do
50
+ it 'posts to syslog' do
51
+ expect(syslog).to receive(:info)
52
+ subject.increment('test.increment', 1)
53
+ end
54
+ end
55
+
56
+ describe '#count' do
57
+ it 'posts to syslog' do
58
+ expect(syslog).to receive(:info)
59
+ subject.count('test.count', 1)
60
+ end
61
+ end
62
+
63
+ describe '#time' do
64
+ it 'posts to syslog' do
65
+ expect(syslog).to receive(:info)
66
+ subject.time('test.time', 1)
67
+ end
68
+ end
69
+
70
+ context 'when calling dynamic methods' do
71
+ describe '#annotate' do
72
+ it 'posts to syslog' do
73
+ expect(syslog).to receive(:info)
74
+ subject.annotate('test.annotate', 'test')
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,103 @@
1
+ require 'blabbermouth'
2
+ require 'rspec'
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ Dir[File.join(File.dirname(__FILE__), '..', "spec/support/**/*.rb")].each { |f| require f }
7
+
8
+ Blabbermouth.configure do |config|
9
+ config.bystanders = []
10
+ end
11
+
12
+ RSpec.configure do |config|
13
+ #config.before(:suite) do
14
+ # ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
15
+ # capture_stdout { load "db/schema.rb" }
16
+ # load 'support/models.rb'
17
+ #end
18
+
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # Many RSpec users commonly either run the entire suite or an individual
43
+ # file, and it's useful to allow more verbose output when running an
44
+ # individual spec file.
45
+ if config.files_to_run.one?
46
+ # Use the documentation formatter for detailed output,
47
+ # unless a formatter has already been configured
48
+ # (e.g. via a command-line flag).
49
+ config.default_formatter = 'doc'
50
+ end
51
+
52
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
53
+ # For more details, see:
54
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
55
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
56
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
57
+ config.disable_monkey_patching!
58
+
59
+ # Run specs in random order to surface order dependencies. If you find an
60
+ # order dependency and want to debug it, you can fix the order by providing
61
+ # the seed, which is printed after each run.
62
+ # --seed 1234
63
+ config.order = :random
64
+
65
+ # Seed global randomization in this process using the `--seed` CLI option.
66
+ # Setting this allows you to use `--seed` to deterministically reproduce
67
+ # test failures related to randomization by passing the same `--seed` value
68
+ # as the one that triggered the failure.
69
+ Kernel.srand config.seed
70
+
71
+ # Print the 10 slowest examples and example groups at the
72
+ # end of the spec run, to help surface which specs are running
73
+ # particularly slow.
74
+ #config.profile_examples = 10
75
+
76
+ # These two settings work together to allow you to limit a spec run
77
+ # to individual examples or groups you care about by tagging them with
78
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
79
+ # get run.
80
+ #config.filter_run :focus
81
+ #config.run_all_when_everything_filtered = true
82
+ end
83
+
84
+ # TODO look into why I need to patch these to work with default behavior?
85
+ class FalseClass
86
+ def false?
87
+ true
88
+ end
89
+
90
+ def true?
91
+ false
92
+ end
93
+ end
94
+
95
+ class TrueClass
96
+ def false?
97
+ false
98
+ end
99
+
100
+ def true?
101
+ true
102
+ end
103
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blabbermouth-syslog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.13
5
+ platform: ruby
6
+ authors:
7
+ - Mark Rebec
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: blabbermouth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Bystander for Blabbermouth that posts to Syslog
56
+ email:
57
+ - mark@markrebec.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/blabbermouth-syslog.rb
63
+ - lib/blabbermouth/syslog/bystander.rb
64
+ - lib/blabbermouth/syslog/version.rb
65
+ - spec/blabbermouth/syslog/bystander_spec.rb
66
+ - spec/spec_helper.rb
67
+ homepage: http://github.com/markrebec/blabbermouth
68
+ licenses: []
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.2.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Syslog bystander for Blabbermouth
90
+ test_files:
91
+ - spec/spec_helper.rb
92
+ - spec/blabbermouth/syslog/bystander_spec.rb