output 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ module Output
14
14
  logger = Logging.logger[name]
15
15
  logger.level = level
16
16
  logger.appenders = Output::Devices.build_device(device_options[:device], device_options)
17
- logger.extend LevelName
17
+ Extension.! logger, LevelName
18
18
  logger
19
19
  end
20
20
  end
@@ -5,6 +5,7 @@ module Output
5
5
  :stdout => Builder::Stdout,
6
6
  :string_io => Builder::StringIo,
7
7
  :file => Builder::File,
8
+ :stderr => Builder::Stderr
8
9
  }
9
10
 
10
11
  default_options = { :name => type, :pattern => DEFAULT_PATTERN }
@@ -20,7 +21,6 @@ module Output
20
21
  Logging.layouts.pattern(:pattern => pattern)
21
22
  end
22
23
 
23
-
24
24
  def build(name, options)
25
25
  pattern = options[:pattern]
26
26
  layout = self.layout(pattern)
@@ -53,7 +53,7 @@ module Output
53
53
  end
54
54
 
55
55
  def build(name, options)
56
- options.extend Output::Devices::OptionValidation
56
+ Extension.! options, Output::Devices::OptionValidation
57
57
  options.validate!(device_id, all_required_options)
58
58
 
59
59
  instance = new
@@ -81,6 +81,13 @@ module Output
81
81
  device :stdout
82
82
  required_options :pattern
83
83
  end
84
+
85
+ class Stderr
86
+ include Builder
87
+
88
+ device :stderr
89
+ required_options :pattern
90
+ end
84
91
  end
85
92
 
86
93
  module OptionValidation
data/lib/output/output.rb CHANGED
@@ -110,7 +110,6 @@ module Output
110
110
  suspend_devices__device_selector device_selector, &block
111
111
  end
112
112
 
113
-
114
113
  def suspend_devices__name(name, &block)
115
114
  device_selector = ->(writer) { writer.device name }
116
115
  suspend_devices__device_selector device_selector, &block
@@ -173,7 +172,6 @@ module Output
173
172
  nil
174
173
  end
175
174
 
176
-
177
175
  def add_device(device)
178
176
  each_writer do |writer|
179
177
  writer.add_device device
@@ -220,7 +218,6 @@ module Output
220
218
  device_options
221
219
  end
222
220
 
223
-
224
221
  def writer_macro(name, options = {}, &message_transformer)
225
222
  level = options[:level] || logger_level
226
223
  options = device_options.merge(options)
@@ -234,6 +231,5 @@ module Output
234
231
  def writer_attribute(name)
235
232
  Writer::Attribute.attribute_name(name)
236
233
  end
237
-
238
234
  end
239
235
  end
data/lib/output/writer.rb CHANGED
@@ -80,8 +80,6 @@ module Output
80
80
  logger.appenders.include? device
81
81
  end
82
82
 
83
-
84
-
85
83
  def remove_device(device)
86
84
  @logger.remove_appenders device
87
85
  device
@@ -138,6 +136,13 @@ module Output
138
136
  device
139
137
  end
140
138
 
139
+ def push_device(device, options = {}, &block)
140
+ return device if device.nil?
141
+ return push_device__obj(device, &block) if device.is_a? Logging::Appender
142
+
143
+ push_device__opts(type = device, options, &block)
144
+ end
145
+
141
146
  def push_device__obj(device, &block)
142
147
  raise "The writer:[#{self.name}] already has a device named #{device.name}:[#{device.class}]" if device?(device)
143
148
 
@@ -152,13 +157,6 @@ module Output
152
157
  device
153
158
  end
154
159
 
155
- def push_device(device, options = {}, &block)
156
- return device if device.nil?
157
- return push_device__obj(device, &block) if device.is_a? Logging::Appender
158
-
159
- push_device__opts(type = device, options, &block)
160
- end
161
-
162
160
  def push_device__opts(type, options = {}, &block)
163
161
  options = self.device_options.merge(options)
164
162
  name = options[:name] || type
data/lib/output.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'logging'
2
- require 'setter'
3
- require 'single'
4
2
  require 'initializer'
3
+ require 'extension'
5
4
 
6
5
  require 'output/devices'
7
6
  require 'output/writer_macro'
8
7
  require 'output/output'
9
8
  require 'output/build_logger'
10
9
  require 'output/writer'
11
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: output
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-21 00:00:00.000000000 Z
12
+ date: 2013-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logging
@@ -27,6 +27,38 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: initializer
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: extension
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
30
62
  description:
31
63
  email:
32
64
  executables: []