em-logger 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,12 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'kramdown'
5
+ gem 'yard'
6
+
7
+ group :test do
8
+ gem 'rspec'
9
+ gem 'simplecov'
10
+ end
2
11
 
3
12
  gemspec
@@ -1,5 +1,7 @@
1
- # encoding: utf-8
2
- require File.expand_path('../lib/em-logger/version', __FILE__)
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'em-logger/version'
3
5
 
4
6
  Gem::Specification.new do |gem|
5
7
  gem.name = 'em-logger'
@@ -12,13 +14,7 @@ Gem::Specification.new do |gem|
12
14
  gem.summary = 'An experimental logger class for EventMachine applications.'
13
15
 
14
16
  gem.add_dependency "eventmachine", ">= 0.12.10"
15
-
16
- gem.add_development_dependency 'rake', '~> 0.9'
17
- gem.add_development_dependency 'rdiscount', '~> 1.6'
18
- gem.add_development_dependency 'rspec', '~> 2.7'
19
- gem.add_development_dependency 'simplecov', '~> 0.5'
20
- gem.add_development_dependency 'yard', '~> 0.7'
21
- gem.add_development_dependency 'em-ventually'
17
+ gem.add_development_dependency 'bundler', '~> 1.0'
22
18
 
23
19
  gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
24
20
  gem.files = `git ls-files`.split("\n")
@@ -27,6 +27,8 @@ module EventMachine
27
27
  end
28
28
 
29
29
  @logger_queue.pop(&queue_processor)
30
+
31
+ EM.add_shutdown_hook { drain } if EM.reactor_running?
30
32
  end
31
33
 
32
34
  def add(severity, message = nil, progname = nil, &block)
@@ -86,5 +88,14 @@ module EventMachine
86
88
  @logger.respond_to?(method, include_private) || super(method, include_private)
87
89
  end
88
90
 
91
+ def drain
92
+ drain_processor = Proc.new do |log_message|
93
+ @logger.add(log_message.severity, log_message.message, log_message.progname)
94
+ end
95
+ while not @logger_queue.empty? do
96
+ @logger_queue.pop(&drain_processor)
97
+ end
98
+ end
99
+
89
100
  end
90
- end
101
+ end
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  class Logger
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -4,13 +4,20 @@ describe EventMachine::Logger do
4
4
  let(:loggr) { ::Logger.new(STDOUT) }
5
5
 
6
6
  context 'creating' do
7
- it 'instatiates with a logger' do
7
+ it 'instantiates with a logger' do
8
8
  EM.run_block do
9
9
  eml = EventMachine::Logger.new(loggr)
10
10
  eml.logger.should eq(loggr)
11
11
  end
12
12
  end
13
13
 
14
+ it 'adds a shutdown hook when the reactor is running' do
15
+ EM.run_block do
16
+ EM.should_receive(:add_shutdown_hook).and_yield
17
+ eml = EventMachine::Logger.new(loggr)
18
+ end
19
+ end
20
+
14
21
  it 'starts the queue processor' do
15
22
  eml = EventMachine::Logger.new(loggr)
16
23
  loggr.should_receive('add').once
@@ -78,6 +85,16 @@ describe EventMachine::Logger do
78
85
  end
79
86
  end
80
87
 
88
+ context 'shutdown' do
89
+ it 'drains the queue on shutdown' do
90
+ eml = EventMachine::Logger.new(loggr)
91
+ eml.logger_queue << EventMachine::LogMessage.new(::Logger::WARN, 'test message', $0)
92
+ # 3.times { eml.add(::Logger::WARN) { 'ohai' } }
93
+ eml.drain
94
+ eml.logger_queue.should be_empty
95
+ end
96
+ end
97
+
81
98
  context 'delegating to logger' do
82
99
  describe 'method_missing' do
83
100
  it 'passes through to the underlying logger' do
@@ -101,4 +118,4 @@ describe EventMachine::Logger do
101
118
  end
102
119
  end
103
120
 
104
- end
121
+ end
@@ -1,5 +1,12 @@
1
1
  # encoding: utf-8
2
- require 'simplecov'
2
+ unless ENV['CI']
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_group 'EM-Logger', 'lib/em-logger'
6
+ add_group 'Specs', 'spec'
7
+ add_filter '.bundle'
8
+ end
9
+ end
3
10
 
4
11
  require 'em-logger'
5
12
  require 'rspec'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-25 00:00:00.000000000 Z
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &70252667255620 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,73 +21,28 @@ dependencies:
21
21
  version: 0.12.10
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70252667255620
25
- - !ruby/object:Gem::Dependency
26
- name: rake
27
- requirement: &70252667255100 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '0.9'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70252667255100
36
- - !ruby/object:Gem::Dependency
37
- name: rdiscount
38
- requirement: &70252667254500 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: '1.6'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70252667254500
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
- requirement: &70252667253740 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
50
25
  none: false
51
26
  requirements:
52
- - - ~>
27
+ - - ! '>='
53
28
  - !ruby/object:Gem::Version
54
- version: '2.7'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70252667253740
29
+ version: 0.12.10
58
30
  - !ruby/object:Gem::Dependency
59
- name: simplecov
60
- requirement: &70252667252980 !ruby/object:Gem::Requirement
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
61
33
  none: false
62
34
  requirements:
63
35
  - - ~>
64
36
  - !ruby/object:Gem::Version
65
- version: '0.5'
37
+ version: '1.0'
66
38
  type: :development
67
39
  prerelease: false
68
- version_requirements: *70252667252980
69
- - !ruby/object:Gem::Dependency
70
- name: yard
71
- requirement: &70252667252440 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
72
41
  none: false
73
42
  requirements:
74
43
  - - ~>
75
44
  - !ruby/object:Gem::Version
76
- version: '0.7'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70252667252440
80
- - !ruby/object:Gem::Dependency
81
- name: em-ventually
82
- requirement: &70252667252060 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
89
- prerelease: false
90
- version_requirements: *70252667252060
45
+ version: '1.0'
91
46
  description: An experimental logger class for EventMachine applications.
92
47
  email: steve.agalloco@gmail.com
93
48
  executables: []
@@ -122,15 +77,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
77
  - - ! '>='
123
78
  - !ruby/object:Gem::Version
124
79
  version: '0'
80
+ segments:
81
+ - 0
82
+ hash: 2261140648683694121
125
83
  required_rubygems_version: !ruby/object:Gem::Requirement
126
84
  none: false
127
85
  requirements:
128
86
  - - ! '>='
129
87
  - !ruby/object:Gem::Version
130
88
  version: '0'
89
+ segments:
90
+ - 0
91
+ hash: 2261140648683694121
131
92
  requirements: []
132
93
  rubyforge_project:
133
- rubygems_version: 1.8.16
94
+ rubygems_version: 1.8.23
134
95
  signing_key:
135
96
  specification_version: 3
136
97
  summary: An experimental logger class for EventMachine applications.