padrino-core 0.14.0 → 0.14.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40709f499ebbaa2e4cd92c62e2142eac2f9c2ab9
4
- data.tar.gz: ff33963d9f849f0bd9676be85e58083c3b932f41
3
+ metadata.gz: 1b80477905af0fe0e47cc92b6640b1201ed1eb20
4
+ data.tar.gz: e26a1c08a6d15e86bcf3b6b971c35f31807c5f03
5
5
  SHA512:
6
- metadata.gz: 057ae19651da64cc6b475f705bbe28f0990d38011883458f7caeec8ed1d2f34e66654e0f8d3da9e1e979757c493b57eaa1c7a21c78f5e20303040c9f8213e968
7
- data.tar.gz: 0d2fdf09929e900e98a25a39dbfbfaa7cadf831c10b8a4ac7bc2d26c80ae840fb645d6b6a16abee3f764e1bafd60738bd354508a35830efd72746476b08536f3
6
+ metadata.gz: 48cdb4f628d9a552648ed7db7a161883c5f93958d10bcc3320c4e5486dab794d5db4db763dd11bd445dfb7deea1aa8e8c55db51d0c3e61ed3f6d0187f5972bda
7
+ data.tar.gz: 7a277cf330b2857c674fb099c39833bc1485402857487d14564f1584b20b0b82f1798c4a95bda165776e332b6087f892c7ab23abe3f004b1861caf8efad814c6
@@ -313,8 +313,13 @@ module Padrino
313
313
  end
314
314
 
315
315
  def self.logger=(logger)
316
- logger.extend(Padrino::Logger::Extensions)
317
-
316
+ unless logger.class.ancestors.include?(Padrino::Logger::Extensions)
317
+ warn <<-EOT
318
+ WARNING! `Padrino.logger = new_logger` no longer extends it with #colorize! and other features.
319
+ To do it with a custom logger you have to manually `new_logger.extend(Padrino::Logger::Extensions)`
320
+ before passing to `Padrino.logger = new_logger`.
321
+ EOT
322
+ end
318
323
  @_logger = logger
319
324
  end
320
325
 
@@ -325,37 +330,37 @@ module Padrino
325
330
  # A {Padrino::Logger} instance
326
331
  #
327
332
  def self.setup!
328
- self.logger = begin
329
- config_level = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym # need this for PADRINO_LOG_LEVEL
330
- config = Config[config_level]
333
+ config_level = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym # need this for PADRINO_LOG_LEVEL
334
+ config = Config[config_level]
331
335
 
332
- unless config
333
- warn("No logging configuration for :#{config_level} found, falling back to :production")
334
- config = Config[:production]
335
- end
336
+ unless config
337
+ warn("No logging configuration for :#{config_level} found, falling back to :production")
338
+ config = Config[:production]
339
+ end
336
340
 
337
- stream = case config[:stream]
338
- when :to_file
339
- if filename = config[:log_path]
340
- filename = Padrino.root(filename) unless Pathname.new(filename).absolute?
341
- if File.directory?(filename)
342
- filename = File.join(filename, "#{Padrino.env}.log")
343
- else
344
- FileUtils.mkdir_p(File.dirname(filename))
345
- end
346
- File.new(filename, 'a+')
341
+ stream = case config[:stream]
342
+ when :to_file
343
+ if filename = config[:log_path]
344
+ filename = Padrino.root(filename) unless Pathname.new(filename).absolute?
345
+ if File.directory?(filename)
346
+ filename = File.join(filename, "#{Padrino.env}.log")
347
347
  else
348
- FileUtils.mkdir_p(Padrino.root('log')) unless File.exist?(Padrino.root('log'))
349
- File.new(Padrino.root('log', "#{Padrino.env}.log"), 'a+')
348
+ FileUtils.mkdir_p(File.dirname(filename))
350
349
  end
351
- when :null then StringIO.new
352
- when :stdout then $stdout
353
- when :stderr then $stderr
354
- else config[:stream] # return itself, probabilly is a custom stream.
355
- end
356
-
357
- Padrino::Logger.new(config.merge(:stream => stream))
350
+ File.new(filename, 'a+')
351
+ else
352
+ FileUtils.mkdir_p(Padrino.root('log')) unless File.exist?(Padrino.root('log'))
353
+ File.new(Padrino.root('log', "#{Padrino.env}.log"), 'a+')
354
+ end
355
+ when :null then StringIO.new
356
+ when :stdout then $stdout
357
+ when :stderr then $stderr
358
+ else config[:stream] # return itself, probabilly is a custom stream.
358
359
  end
360
+
361
+ new_logger = Padrino::Logger.new(config.merge(:stream => stream))
362
+ new_logger.extend(Padrino::Logger::Extensions)
363
+ self.logger = new_logger
359
364
  end
360
365
 
361
366
  ##
@@ -6,7 +6,7 @@
6
6
  #
7
7
  module Padrino
8
8
  # The version constant for the current version of Padrino.
9
- VERSION = '0.14.0' unless defined?(Padrino::VERSION)
9
+ VERSION = '0.14.0.1' unless defined?(Padrino::VERSION)
10
10
 
11
11
  #
12
12
  # The current Padrino version.
data/test/test_logger.rb CHANGED
@@ -196,7 +196,9 @@ describe "alternate logger" do
196
196
  before do
197
197
  @save_logger = Padrino.logger
198
198
  @log = StringIO.new
199
- Padrino.logger = FancyLogger.new(@log)
199
+ new_logger = FancyLogger.new(@log)
200
+ new_logger.extend(Padrino::Logger::Extensions)
201
+ capture_io { Padrino.logger = new_logger }
200
202
  end
201
203
 
202
204
  after do
@@ -223,11 +225,34 @@ describe "alternate logger" do
223
225
  end
224
226
  end
225
227
 
228
+ describe "binary logger" do
229
+ before do
230
+ @save_logger = Padrino.logger
231
+ @log = StringIO.new
232
+ new_logger = Logger.new(@log)
233
+ new_logger.formatter = proc do |_, _, _, message|
234
+ "#{message.size}"
235
+ end
236
+ capture_io { Padrino.logger = new_logger }
237
+ end
238
+
239
+ after do
240
+ Padrino.logger = @save_logger
241
+ end
242
+
243
+ it 'should not convert parameters to strings before formatting' do
244
+ logger.info({:a => 2})
245
+ assert_equal "1", @log.string
246
+ end
247
+ end
248
+
226
249
  describe "alternate logger: stdlib logger" do
227
250
  before do
228
251
  @log = StringIO.new
229
252
  @save_logger = Padrino.logger
230
- Padrino.logger = Logger.new(@log)
253
+ new_logger = Logger.new(@log)
254
+ new_logger.extend(Padrino::Logger::Extensions)
255
+ capture_io { Padrino.logger = new_logger }
231
256
  end
232
257
 
233
258
  after do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.14.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-03-15 00:00:00.000000000 Z
14
+ date: 2017-03-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-support
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.14.0
22
+ version: 0.14.0.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.14.0
29
+ version: 0.14.0.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sinatra
32
32
  requirement: !ruby/object:Gem::Requirement