yell 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Gemfile +2 -1
- data/lib/yell.rb +17 -3
- data/lib/yell/adapters.rb +15 -0
- data/lib/yell/adapters/base.rb +3 -6
- data/lib/yell/adapters/datefile.rb +0 -2
- data/lib/yell/adapters/file.rb +0 -2
- data/lib/yell/adapters/streams.rb +0 -3
- data/lib/yell/event.rb +6 -2
- data/lib/yell/formatter.rb +70 -19
- data/lib/yell/helpers/{adapters.rb → adapter.rb} +16 -7
- data/lib/yell/logger.rb +13 -13
- data/lib/yell/version.rb +1 -1
- data/spec/threaded/yell_spec.rb +1 -0
- data/spec/yell/formatter_spec.rb +28 -18
- data/spec/yell/logger_spec.rb +15 -26
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTI3NDViZDY2MmQ1M2JlNjFiYmIxY2RkOWU0NzQ0MWFmY2RiYmNlZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDQxN2VlMjY4Nzc5Nzg3MjZjYmFiYTk3MTg1MjNhODU2ODAzMDE5MQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDczNmE5NGFlN2E5MGZiNmI0OGNmOTRmYTY2ODliNjc1MDBlZDIyZWFkMzU1
|
10
|
+
OTk4NTAwZWFjMDFjMmQzMGU5YTkyNzcwMGE5MTRkODA0ODFiODYwMTM5ZTgy
|
11
|
+
ZWVhNWUxNWMwOTU3MTIyZDc2ZThiNTAwNzE3Njk4NDVmMTg2NmM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTNhMGVkY2NmZGQ5NWUwNjU3YmQ1MjY2MGQ4OThhNTFhNTc1MTZhYTA0NGM3
|
14
|
+
YmIxYzY1NjZiOTRiM2UzNzNlYjA2NWYxMzg5Y2ExOWVmNjFiYzgwM2Q4YzZi
|
15
|
+
ODMyNjU1NzMzN2QxZmNjMTQ2YmRlZDhkOTZmZGU4YmFlOGVmYjQ=
|
data/Gemfile
CHANGED
data/lib/yell.rb
CHANGED
@@ -60,8 +60,8 @@ module Yell #:nodoc:
|
|
60
60
|
# Shortcut to Yell::Fomatter.new
|
61
61
|
#
|
62
62
|
# @return [Yell::Formatter] A Yell::Formatter instance
|
63
|
-
def format( pattern, date_pattern = nil )
|
64
|
-
Yell::Formatter.new(pattern, date_pattern)
|
63
|
+
def format( pattern = nil, date_pattern = nil, &block )
|
64
|
+
Yell::Formatter.new(pattern, date_pattern, &block)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Loads a config from a YAML file
|
@@ -71,6 +71,11 @@ module Yell #:nodoc:
|
|
71
71
|
Yell.new Yell::Configuration.load!(file)
|
72
72
|
end
|
73
73
|
|
74
|
+
# Shortcut to Yell::Adapters.register
|
75
|
+
def register( name, klass )
|
76
|
+
Yell::Adapters.register(name, klass)
|
77
|
+
end
|
78
|
+
|
74
79
|
# @private
|
75
80
|
def env
|
76
81
|
return ENV['YELL_ENV'] if ENV.key? 'YELL_ENV'
|
@@ -105,7 +110,7 @@ end
|
|
105
110
|
|
106
111
|
# helpers
|
107
112
|
require File.dirname(__FILE__) + '/yell/helpers/base'
|
108
|
-
require File.dirname(__FILE__) + '/yell/helpers/
|
113
|
+
require File.dirname(__FILE__) + '/yell/helpers/adapter'
|
109
114
|
require File.dirname(__FILE__) + '/yell/helpers/formatter'
|
110
115
|
require File.dirname(__FILE__) + '/yell/helpers/level'
|
111
116
|
require File.dirname(__FILE__) + '/yell/helpers/tracer'
|
@@ -124,3 +129,12 @@ require File.dirname(__FILE__) + '/yell/logger'
|
|
124
129
|
# modules
|
125
130
|
require File.dirname(__FILE__) + '/yell/loggable'
|
126
131
|
|
132
|
+
# register known adapters
|
133
|
+
Yell.register :null, Yell::Adapters::Base # adapter that does nothing (for convenience only)
|
134
|
+
Yell.register :file, Yell::Adapters::File
|
135
|
+
Yell.register :datefile, Yell::Adapters::Datefile
|
136
|
+
Yell.register :stdout, Yell::Adapters::Stdout
|
137
|
+
Yell.register :stderr, Yell::Adapters::Stderr
|
138
|
+
|
139
|
+
|
140
|
+
|
data/lib/yell/adapters.rb
CHANGED
@@ -39,6 +39,21 @@ module Yell #:nodoc:
|
|
39
39
|
adapter.new(options, &block)
|
40
40
|
end
|
41
41
|
|
42
|
+
# Thanks, railties :-)
|
43
|
+
def self.broadcast( adapter )
|
44
|
+
Module.new do
|
45
|
+
define_method(:write) do |event|
|
46
|
+
adapter.write(event)
|
47
|
+
super(event)
|
48
|
+
end
|
49
|
+
|
50
|
+
define_method(:close) do
|
51
|
+
adapter.close
|
52
|
+
super()
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
end
|
43
58
|
end
|
44
59
|
|
data/lib/yell/adapters/base.rb
CHANGED
@@ -155,7 +155,7 @@ module Yell #:nodoc:
|
|
155
155
|
# make sure the adapter is closed and re-raise the exception
|
156
156
|
synchronize { close }
|
157
157
|
|
158
|
-
raise(
|
158
|
+
raise(e)
|
159
159
|
end
|
160
160
|
|
161
161
|
# Close the adapter (stream, connection, etc).
|
@@ -172,11 +172,8 @@ module Yell #:nodoc:
|
|
172
172
|
"#<#{self.class.name} #{inspection * ', '}>"
|
173
173
|
end
|
174
174
|
|
175
|
-
private
|
176
175
|
|
177
|
-
|
178
|
-
# super()
|
179
|
-
# end
|
176
|
+
private
|
180
177
|
|
181
178
|
# Setup the adapter instance.
|
182
179
|
#
|
@@ -219,7 +216,7 @@ module Yell #:nodoc:
|
|
219
216
|
#
|
220
217
|
# @return [Boolean] true or false
|
221
218
|
def write?( event )
|
222
|
-
@level.nil? || @level.at?(
|
219
|
+
@level.nil? || @level.at?(event.level)
|
223
220
|
end
|
224
221
|
|
225
222
|
# Get an array of inspected attributes for the adapter.
|
data/lib/yell/adapters/file.rb
CHANGED
data/lib/yell/event.rb
CHANGED
@@ -27,10 +27,14 @@ module Yell #:nodoc:
|
|
27
27
|
# Accessor to the time the log event occured
|
28
28
|
attr_reader :time
|
29
29
|
|
30
|
+
# Accessor to the logger's name
|
31
|
+
attr_reader :name
|
32
|
+
|
30
33
|
|
31
34
|
def initialize(logger, level, *messages, &block)
|
32
|
-
@time
|
33
|
-
@level
|
35
|
+
@time = Time.now
|
36
|
+
@level = level
|
37
|
+
@name = logger.name
|
34
38
|
|
35
39
|
@messages = messages
|
36
40
|
@messages << block.call if block
|
data/lib/yell/formatter.rb
CHANGED
@@ -58,7 +58,8 @@ module Yell #:nodoc:
|
|
58
58
|
"F" => "event.file", # Path with filename where the logger was called
|
59
59
|
"f" => "File.basename(event.file)", # Filename where the loger was called
|
60
60
|
"M" => "event.method", # Method name where the logger was called
|
61
|
-
"n" => "event.line"
|
61
|
+
"n" => "event.line", # Line where the logger was called
|
62
|
+
"N" => "event.name" # Name of the logger
|
62
63
|
}
|
63
64
|
|
64
65
|
Matcher = /([^%]*)(%\d*)?(#{Table.keys.join('|')})?(.*)/
|
@@ -66,12 +67,29 @@ module Yell #:nodoc:
|
|
66
67
|
|
67
68
|
# Initializes a new +Yell::Formatter+.
|
68
69
|
#
|
69
|
-
# Upon initialization it defines a format method. `format` takes
|
70
|
-
# a {Yell::Event} instance as agument in order to apply for desired log
|
70
|
+
# Upon initialization it defines a format method. `format` takes
|
71
|
+
# a {Yell::Event} instance as agument in order to apply for desired log
|
71
72
|
# message formatting.
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
#
|
74
|
+
# @example Blank formatter
|
75
|
+
# Formatter.new
|
76
|
+
#
|
77
|
+
# @example Formatter with a message pattern
|
78
|
+
# Formatter.new("%d [%5L] %p : %m")
|
79
|
+
#
|
80
|
+
# @example Formatter with a message and date pattern
|
81
|
+
# Formatter.new("%d [%5L] %p : %m", "%D %H:%M:%S.%L")
|
82
|
+
#
|
83
|
+
# @example Formatter with a message modifier
|
84
|
+
# Formatter.new do |f|
|
85
|
+
# f.modify(Hash) { |h| "Hash: #{h.inspect}" }
|
86
|
+
# end
|
87
|
+
def initialize( *args, &block )
|
88
|
+
builder = Builder.new(*args, &block)
|
89
|
+
|
90
|
+
@pattern = builder.pattern
|
91
|
+
@date_pattern = builder.date_pattern
|
92
|
+
@modifier = builder.modifier
|
75
93
|
|
76
94
|
define_date_method!
|
77
95
|
define_format_method!
|
@@ -85,6 +103,51 @@ module Yell #:nodoc:
|
|
85
103
|
|
86
104
|
private
|
87
105
|
|
106
|
+
# Message modifier class to allow different modifiers for different requirements.
|
107
|
+
class Modifier
|
108
|
+
def initialize
|
109
|
+
@repository = {}
|
110
|
+
end
|
111
|
+
|
112
|
+
def set( key, &block )
|
113
|
+
@repository.merge!(key => block)
|
114
|
+
end
|
115
|
+
|
116
|
+
def call( message )
|
117
|
+
case
|
118
|
+
when mod = @repository[message.class] || @repository[message.class.to_s]
|
119
|
+
mod.call(message)
|
120
|
+
when message.is_a?(Hash)
|
121
|
+
message.map { |k,v| "#{k}: #{v}" }.join(", ")
|
122
|
+
when message.is_a?(Exception)
|
123
|
+
backtrace = message.backtrace ? "\n\t#{message.backtrace.join("\n\t")}" : ""
|
124
|
+
sprintf("%s: %s%s", message.class, message.message, backtrace)
|
125
|
+
else
|
126
|
+
message
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Builder class to allow setters that won't be accessible once
|
132
|
+
# transferred to the Formatter
|
133
|
+
class Builder
|
134
|
+
attr_accessor :pattern, :date_pattern
|
135
|
+
attr_reader :modifier
|
136
|
+
|
137
|
+
def initialize( pattern = nil, date_pattern = nil, &block )
|
138
|
+
@modifier = Modifier.new
|
139
|
+
|
140
|
+
@pattern = pattern || Yell::DefaultFormat
|
141
|
+
@date_pattern = date_pattern || :iso8601
|
142
|
+
|
143
|
+
block.call(self) if block
|
144
|
+
end
|
145
|
+
|
146
|
+
def modify( key, &block )
|
147
|
+
modifier.set(key, &block)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
88
151
|
def define_date_method!
|
89
152
|
buf = case @date_pattern
|
90
153
|
when String then "t.strftime(@date_pattern)"
|
@@ -141,19 +204,7 @@ module Yell #:nodoc:
|
|
141
204
|
end
|
142
205
|
|
143
206
|
def message( *messages )
|
144
|
-
messages.map { |m|
|
145
|
-
end
|
146
|
-
|
147
|
-
def to_message( m )
|
148
|
-
case m
|
149
|
-
when Hash
|
150
|
-
m.map { |k,v| "#{k}: #{v}" }.join( ", " )
|
151
|
-
when Exception
|
152
|
-
backtrace = m.backtrace ? "\n\t#{m.backtrace.join("\n\t")}" : ""
|
153
|
-
sprintf("%s: %s%s", m.class, m.message, backtrace)
|
154
|
-
else
|
155
|
-
m
|
156
|
-
end
|
207
|
+
messages.map { |m| @modifier.call(m) }.join(" ")
|
157
208
|
end
|
158
209
|
|
159
210
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Yell #:nodoc:
|
3
3
|
module Helpers #:nodoc:
|
4
|
-
module
|
4
|
+
module Adapter #:nodoc:
|
5
5
|
|
6
6
|
# Define an adapter to be used for logging.
|
7
7
|
#
|
@@ -18,29 +18,38 @@ module Yell #:nodoc:
|
|
18
18
|
# adapter :file, 'development.log', :level => :warn
|
19
19
|
#
|
20
20
|
# @example Set the adapter directly from an adapter instance
|
21
|
-
# adapter
|
21
|
+
# adapter Yell::Adapter::File.new
|
22
22
|
#
|
23
23
|
# @param [Symbol] type The type of the adapter, may be `:file` or `:datefile` (default `:file`)
|
24
24
|
# @return [Yell::Adapter] The instance
|
25
25
|
# @raise [Yell::NoSuchAdapter] Will be thrown when the adapter is not defined
|
26
26
|
def adapter( type = :file, *args, &block )
|
27
|
-
options = [@options, *args].inject(
|
27
|
+
options = [@options, *args].inject(Hash.new) do |h, c|
|
28
28
|
h.merge( [String, Pathname].include?(c.class) ? {:filename => c} : c )
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
new_adapter = Yell::Adapters.new(type, options, &block)
|
32
|
+
|
33
|
+
# Also replaces the :null logger of type Yell::Adapters::Base
|
34
|
+
if @_adapter.nil? || @_adapter.instance_of?(Yell::Adapters::Base)
|
35
|
+
@_adapter = new_adapter
|
36
|
+
else
|
37
|
+
@_adapter.extend(Yell::Adapters.broadcast(new_adapter))
|
38
|
+
end
|
39
|
+
|
40
|
+
_adapter
|
32
41
|
end
|
33
42
|
|
34
43
|
# @private
|
35
|
-
def
|
36
|
-
@
|
44
|
+
def _adapter
|
45
|
+
@_adapter
|
37
46
|
end
|
38
47
|
|
39
48
|
|
40
49
|
private
|
41
50
|
|
42
51
|
def reset!
|
43
|
-
@
|
52
|
+
@_adapter = nil
|
44
53
|
|
45
54
|
super
|
46
55
|
end
|
data/lib/yell/logger.rb
CHANGED
@@ -38,7 +38,7 @@ module Yell #:nodoc:
|
|
38
38
|
include Yell::Helpers::Base
|
39
39
|
include Yell::Helpers::Level
|
40
40
|
include Yell::Helpers::Formatter
|
41
|
-
include Yell::Helpers::
|
41
|
+
include Yell::Helpers::Adapter
|
42
42
|
include Yell::Helpers::Tracer
|
43
43
|
include Yell::Helpers::Silencer
|
44
44
|
|
@@ -74,14 +74,14 @@ module Yell #:nodoc:
|
|
74
74
|
@options = args.last.is_a?(Hash) ? args.pop : {}
|
75
75
|
|
76
76
|
# adapters may be passed in the options
|
77
|
-
extract!(@options)
|
77
|
+
extract!(*@options[:adapters]) if @options.key?(:adapters)
|
78
78
|
|
79
79
|
# check if filename was given as argument and put it into the @options
|
80
80
|
if [String, Pathname].include?(args.last.class)
|
81
81
|
@options[:filename] = args.pop unless @options[:filename]
|
82
82
|
end
|
83
83
|
|
84
|
-
self.level = @options.fetch(:level, 0) # debug by
|
84
|
+
self.level = @options.fetch(:level, 0) # debug by default
|
85
85
|
self.name = @options.fetch(:name, nil) # no name by default
|
86
86
|
self.trace = @options.fetch(:trace, :error) # trace from :error level onwards
|
87
87
|
|
@@ -95,7 +95,7 @@ module Yell #:nodoc:
|
|
95
95
|
block.arity > 0 ? block.call(self) : instance_eval(&block) if block_given?
|
96
96
|
|
97
97
|
# default adapter when none defined
|
98
|
-
self.adapter(:file) if
|
98
|
+
self.adapter(:file) if _adapter.nil?
|
99
99
|
end
|
100
100
|
|
101
101
|
|
@@ -138,12 +138,12 @@ module Yell #:nodoc:
|
|
138
138
|
# Get a pretty string representation of the logger.
|
139
139
|
def inspect
|
140
140
|
inspection = inspectables.map { |m| "#{m}: #{send(m).inspect}" }
|
141
|
-
"#<#{self.class.name} #{inspection * ', '}
|
141
|
+
"#<#{self.class.name} #{inspection * ', '}>"
|
142
142
|
end
|
143
143
|
|
144
144
|
# @private
|
145
145
|
def close
|
146
|
-
|
146
|
+
_adapter.close
|
147
147
|
end
|
148
148
|
|
149
149
|
|
@@ -153,22 +153,22 @@ module Yell #:nodoc:
|
|
153
153
|
# multiple variations:
|
154
154
|
#
|
155
155
|
# @example
|
156
|
-
#
|
156
|
+
# extract!(:stdout, :stderr)
|
157
157
|
#
|
158
158
|
# @example
|
159
|
-
#
|
160
|
-
def extract!(
|
161
|
-
|
159
|
+
# extract!(:stdout => {:level => :info}, :stderr => {:level => :error})
|
160
|
+
def extract!( *adapters )
|
161
|
+
adapters.each do |a|
|
162
162
|
case a
|
163
|
-
when
|
164
|
-
else
|
163
|
+
when Hash then a.each { |t, o| adapter(t, o) }
|
164
|
+
else adapter(a)
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
169
|
# Cycles all the adapters and writes the message
|
170
170
|
def write( event )
|
171
|
-
|
171
|
+
_adapter.write(event)
|
172
172
|
end
|
173
173
|
|
174
174
|
# Get an array of inspected attributes for the adapter.
|
data/lib/yell/version.rb
CHANGED
data/spec/threaded/yell_spec.rb
CHANGED
data/spec/yell/formatter_spec.rb
CHANGED
@@ -2,20 +2,22 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Yell::Formatter do
|
4
4
|
|
5
|
-
let(:logger) { Yell::Logger.new }
|
6
|
-
let(:
|
7
|
-
let(:
|
5
|
+
let(:logger) { Yell::Logger.new(:stdout, :name => 'Yell') }
|
6
|
+
let(:message) { "Hello World!" }
|
7
|
+
let(:event) { Yell::Event.new(logger, 1, message) }
|
8
8
|
|
9
9
|
let(:pattern) { "%m" }
|
10
10
|
let(:formatter) { Yell::Formatter.new(pattern) }
|
11
11
|
|
12
|
+
let(:time) { Time.now }
|
13
|
+
|
14
|
+
subject { formatter.format(event) }
|
15
|
+
|
12
16
|
before do
|
13
17
|
Timecop.freeze(time)
|
14
18
|
end
|
15
19
|
|
16
|
-
describe "
|
17
|
-
subject { formatter.format(event) }
|
18
|
-
|
20
|
+
describe "patterns" do
|
19
21
|
context "%m" do
|
20
22
|
let(:pattern) { "%m" }
|
21
23
|
it { should eq(event.messages.join(' ')) }
|
@@ -45,6 +47,7 @@ describe Yell::Formatter do
|
|
45
47
|
let(:pattern) { "%P" }
|
46
48
|
it { should eq(event.progname) }
|
47
49
|
end
|
50
|
+
|
48
51
|
context "%t" do
|
49
52
|
let(:pattern) { "%t" }
|
50
53
|
it { should eq(event.thread_id.to_s) }
|
@@ -86,11 +89,14 @@ describe Yell::Formatter do
|
|
86
89
|
it { should eq("123") }
|
87
90
|
end
|
88
91
|
end
|
89
|
-
end
|
90
92
|
|
91
|
-
|
92
|
-
|
93
|
+
context "%N" do
|
94
|
+
let(:pattern) { "%N" }
|
95
|
+
it { should eq("Yell") }
|
96
|
+
end
|
97
|
+
end
|
93
98
|
|
99
|
+
describe "presets" do
|
94
100
|
context "NoFormat" do
|
95
101
|
let(:pattern) { Yell::NoFormat }
|
96
102
|
it { should eq("Hello World!") }
|
@@ -112,25 +118,29 @@ describe Yell::Formatter do
|
|
112
118
|
end
|
113
119
|
end
|
114
120
|
|
115
|
-
describe "
|
116
|
-
let(:
|
117
|
-
let(:event) { Yell::Event.new(logger, 1, exception) }
|
118
|
-
subject { formatter.format(event) }
|
121
|
+
describe "Exception" do
|
122
|
+
let(:message) { StandardError.new("This is an Exception") }
|
119
123
|
|
120
124
|
before do
|
121
|
-
|
125
|
+
stub(message).backtrace { ["backtrace"] }
|
122
126
|
end
|
123
127
|
|
124
128
|
it { should eq("StandardError: This is an Exception\n\tbacktrace") }
|
125
129
|
end
|
126
130
|
|
127
|
-
describe "
|
128
|
-
let(:
|
129
|
-
let(:event) { Yell::Event.new(logger, 1, hash) }
|
130
|
-
subject { formatter.format(event) }
|
131
|
+
describe "Hash" do
|
132
|
+
let(:message) { {:test => 'message'} }
|
131
133
|
|
132
134
|
it { should eq("test: message") }
|
133
135
|
end
|
134
136
|
|
137
|
+
describe "custom message modifiers" do
|
138
|
+
let(:formatter) do
|
139
|
+
Yell::Formatter.new(pattern) { |f| f.modify(String) { |m| "Modified! #{m}" } }
|
140
|
+
end
|
141
|
+
|
142
|
+
it { should eq("Modified! #{message}") }
|
143
|
+
end
|
144
|
+
|
135
145
|
end
|
136
146
|
|
data/spec/yell/logger_spec.rb
CHANGED
@@ -41,11 +41,10 @@ describe Yell::Logger do
|
|
41
41
|
it { should respond_to(:unknown?) }
|
42
42
|
end
|
43
43
|
|
44
|
-
context "default #
|
45
|
-
subject { logger.
|
44
|
+
context "default #adapter" do
|
45
|
+
subject { logger._adapter }
|
46
46
|
|
47
|
-
|
48
|
-
its(:first) { should be_kind_of(Yell::Adapters::File) }
|
47
|
+
it { should be_kind_of(Yell::Adapters::File) }
|
49
48
|
end
|
50
49
|
|
51
50
|
context "default #level" do
|
@@ -67,6 +66,10 @@ describe Yell::Logger do
|
|
67
66
|
let(:name) { 'test' }
|
68
67
|
let!(:logger) { Yell.new(:name => name) }
|
69
68
|
|
69
|
+
it "should set the name correctly" do
|
70
|
+
expect(logger.name).to eq(name)
|
71
|
+
end
|
72
|
+
|
70
73
|
it "should be added to the repository" do
|
71
74
|
expect(Yell::Repository[name]).to eq(logger)
|
72
75
|
end
|
@@ -152,8 +155,7 @@ describe Yell::Logger do
|
|
152
155
|
end
|
153
156
|
|
154
157
|
its(:level) { should eq(level) }
|
155
|
-
its(
|
156
|
-
its('adapters.first') { should be_instance_of(Yell::Adapters::Stdout) }
|
158
|
+
its(:_adapter) { should be_instance_of(Yell::Adapters::Stdout) }
|
157
159
|
end
|
158
160
|
|
159
161
|
context "without arity" do
|
@@ -162,31 +164,18 @@ describe Yell::Logger do
|
|
162
164
|
end
|
163
165
|
|
164
166
|
its(:level) { should eq(level) }
|
165
|
-
its(
|
166
|
-
its('adapters.first') { should be_instance_of(Yell::Adapters::Stdout) }
|
167
|
+
its(:_adapter) { should be_instance_of(Yell::Adapters::Stdout) }
|
167
168
|
end
|
168
169
|
end
|
169
170
|
|
170
171
|
context "initialize with #adapters option" do
|
171
|
-
|
172
|
-
Yell::Logger
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
let(:stdout) { adapters.first }
|
177
|
-
let(:stderr) { adapters.last }
|
178
|
-
|
179
|
-
it "should define those adapters" do
|
180
|
-
expect(adapters.size).to eq(2)
|
181
|
-
|
182
|
-
expect(stdout).to be_kind_of(Yell::Adapters::Stdout)
|
183
|
-
expect(stderr).to be_kind_of(Yell::Adapters::Stderr)
|
184
|
-
end
|
172
|
+
it "should set adapters in logger correctly" do
|
173
|
+
any_instance_of(Yell::Logger) do |logger|
|
174
|
+
mock.proxy(logger).adapter(:stdout)
|
175
|
+
mock.proxy(logger).adapter(:stderr, :level => :error)
|
176
|
+
end
|
185
177
|
|
186
|
-
|
187
|
-
expect(stderr.level.at?(:warn)).to be_false
|
188
|
-
expect(stderr.level.at?(:error)).to be_true
|
189
|
-
expect(stderr.level.at?(:fatal)).to be_true
|
178
|
+
Yell::Logger.new(:adapters => [:stdout, {:stderr => {:level => :error}}])
|
190
179
|
end
|
191
180
|
end
|
192
181
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rudolf Schmidt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Yell - Your Extensible Logging Library. Define multiple adapters, various
|
14
14
|
log level combinations or message formatting options like you've never done before
|
@@ -45,7 +45,7 @@ files:
|
|
45
45
|
- lib/yell/configuration.rb
|
46
46
|
- lib/yell/event.rb
|
47
47
|
- lib/yell/formatter.rb
|
48
|
-
- lib/yell/helpers/
|
48
|
+
- lib/yell/helpers/adapter.rb
|
49
49
|
- lib/yell/helpers/base.rb
|
50
50
|
- lib/yell/helpers/formatter.rb
|
51
51
|
- lib/yell/helpers/level.rb
|
@@ -85,17 +85,17 @@ require_paths:
|
|
85
85
|
- lib
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - '>='
|
88
|
+
- - ! '>='
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - '>='
|
93
|
+
- - ! '>='
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project: yell
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.1.5
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Yell - Your Extensible Logging Library
|
@@ -118,3 +118,4 @@ test_files:
|
|
118
118
|
- spec/yell/repository_spec.rb
|
119
119
|
- spec/yell/silencer_spec.rb
|
120
120
|
- spec/yell_spec.rb
|
121
|
+
has_rdoc:
|