catamaran 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 070bb5224a0412112c13ca5981859b8d201be22d
4
- data.tar.gz: 2192f55d66d64d284a20bc409a1c0a2cc92c795e
3
+ metadata.gz: c51065cdb4214656604cdb61802d5eb574698f5f
4
+ data.tar.gz: 7fa689f18bade04142e110bc5693b6370e168034
5
5
  SHA512:
6
- metadata.gz: b809ca0a2dcf06b23aa5eddb66820781ed28c978da4e16a9d45e4e2d3f0fa250f5074fa4e746405211e3eea7d46599193d7e861769add0b858bdb081fa3cae8e
7
- data.tar.gz: 1fc5c6ff9a835959cc43833e0c39fa250c32188c8eba73b89fe5d41738e078c972d10362e0f795b3307604b43f533e575e064e91b9e194c3251818a8850812cc
6
+ metadata.gz: e6f186c028aa5ce1cd5db49971b723862d7e141f0fc9daf902dee4a1961ec9e4667bb83681b177bde6d6c037ef7e47419379de11fca2576c752a0b32eb431655
7
+ data.tar.gz: 7b7750e9d5eaaeb882902b0637b0f9ae2b7e3cec5d444093a6e23ddf9e1b6f68239e421e64e9d4876f8340e131a7c5487f684a139fc48651f316a9ca7267f997
data/README.md CHANGED
@@ -6,7 +6,7 @@ Logging is a powerful and often undervalued tool in software development. When
6
6
  Gemfile
7
7
  -------
8
8
 
9
- gem 'catamaran', '~> 0.9.0'
9
+ gem 'catamaran', '~> 0.9.1'
10
10
 
11
11
  Rails-related setup:
12
12
 
@@ -129,7 +129,7 @@ I'm looking for a logging utility that:
129
129
  * captures from where each log entry was generated
130
130
  * works equally well with classes that do and do *not* extend Rails base classes
131
131
  * supports the TRACE log level (or other log level less critical than DEBUG).
132
- * is capable of capturing logs at different log level thresholds from different parts of the app simultaneously
132
+ * is capable of capturing logs at different severity thresholds from different parts of the app simultaneously
133
133
  * readily works with Rails
134
134
  * http://stackoverflow.com/questions/462651/rails-logger-format-string-configuration
135
135
  * http://stackoverflow.com/questions/3654827/logging-in-rails-app
@@ -4,9 +4,10 @@ module Catamaran
4
4
  # If that's too verbose, the level can be changed to IO_LESS_CRITICAL_THAN_DEBUG and logger.io messages won't be
5
5
  # visible unless the log level is set to TRACE.
6
6
  # See development.rb for an example of this
7
+ IO_LESS_CRITICAL_THAN_TRACE = 1780
7
8
  IO_LESS_CRITICAL_THAN_DEBUG = 2780
8
9
  IO_LESS_CRITICAL_THAN_INFO = 3780
9
- IO_LESS_CRITICAL_THAN_NOTICE = 4780
10
+
10
11
 
11
12
  ALL = 100
12
13
 
@@ -51,12 +52,12 @@ module Catamaran
51
52
  'SEVERE'
52
53
  when FATAL
53
54
  'FATAL'
55
+ when IO_LESS_CRITICAL_THAN_TRACE
56
+ 'IO'
54
57
  when IO_LESS_CRITICAL_THAN_INFO
55
58
  'IO'
56
59
  when IO_LESS_CRITICAL_THAN_DEBUG
57
- 'IO'
58
- when IO_LESS_CRITICAL_THAN_NOTICE
59
- 'IO'
60
+ 'IO'
60
61
  else
61
62
  # Unknown
62
63
  ''
@@ -10,8 +10,8 @@ module Catamaran
10
10
  # The getter associated with retrieving the current log level for this logger.
11
11
  # Similar is the smart_log_level getter
12
12
 
13
- def log_level( opts = {} )
14
- if instance_variable_defined?( :@log_level ) && @log_level
13
+ def log_level( opts = nil )
14
+ if @log_level
15
15
  # Implicit return
16
16
  @log_level
17
17
  elsif self.parent.nil?
@@ -20,11 +20,11 @@ module Catamaran
20
20
  # Implicit return
21
21
  Catamaran::LogLevel::NOTICE
22
22
  else
23
- recursive = ( opts[:recursive] == true || opts[:be_populated] == true )
23
+ recursive = ( opts && ( opts[:recursive] == true || opts[:be_populated] == true ) )
24
24
  if recursive == true
25
25
 
26
26
  # Remember the log level we found so we don't have to recursively look for it ever time
27
- if !instance_variable_defined?( :@memoized_log_level ) || @memoized_log_level.nil?
27
+ if @memoized_log_level.nil?
28
28
  @memoized_log_level = parent.log_level( opts ) if parent
29
29
  end
30
30
 
@@ -52,7 +52,7 @@ module Catamaran
52
52
 
53
53
  def log_level=( value )
54
54
  @log_level = value
55
- remove_instance_variable( :@memoized_log_level ) if instance_variable_defined?( :@memoized_log_level )
55
+ @memoized_log_level = nil
56
56
  end
57
57
 
58
58
 
@@ -67,7 +67,7 @@ module Catamaran
67
67
 
68
68
 
69
69
  def backtrace_log_level( opts = {} )
70
- if instance_variable_defined?( :@backtrace_log_level ) && @backtrace_log_level
70
+ if @backtrace_log_level
71
71
  retval = @backtrace_log_level
72
72
  elsif self.parent.nil?
73
73
  # No parent means this logger(self) is the root logger. So use the default log level
@@ -77,7 +77,7 @@ module Catamaran
77
77
  if recursive == true
78
78
 
79
79
  # Remember the log level we found so we don't have to recursively look for it ever time
80
- if !instance_variable_defined?( :@memoized_backtrace_log_level ) || @memoized_backtrace_log_level.nil?
80
+ if @memoized_backtrace_log_level.nil?
81
81
  @memoized_backtrace_log_level = parent.backtrace_log_level( opts ) if parent
82
82
  end
83
83
 
@@ -105,7 +105,7 @@ module Catamaran
105
105
 
106
106
  def backtrace_log_level=( value )
107
107
  @backtrace_log_level = value
108
- remove_instance_variable( :@memoized_backtrace_log_level ) if instance_variable_defined?( :@memoized_backtrace_log_level )
108
+ @memoized_backtrace_log_level = nil
109
109
  end
110
110
 
111
111
 
@@ -387,7 +387,9 @@ module Catamaran
387
387
  # Forget any cached memoization log levels within this logger or within sub-loggers of this logger
388
388
 
389
389
  def forget_memoizations
390
- remove_instance_variable(:@memoized_log_level) if instance_variable_defined?( :@memoized_log_level )
390
+ @memoized_log_level = nil
391
+ @memoized_backtrace_log_level = nil
392
+
391
393
  @sub_loggers.values.each do |logger|
392
394
  logger.forget_memoizations()
393
395
  end
@@ -412,12 +414,15 @@ module Catamaran
412
414
 
413
415
  ##
414
416
  # I used to delete the root level logger, but now I reset it instead.
415
- # Among other reasons, the CatLogger constant now works
417
+ # Among other reasons, the CatLogger constant now works.
418
+ # Unless otherwise specified, a reset() is a soft reset by default.
416
419
 
417
420
  def reset( opts = {} )
418
- remove_instance_variable(:@memoized_log_level) if instance_variable_defined?( :@memoized_log_level )
419
- remove_instance_variable(:@log_level) if instance_variable_defined?( :@log_level )
420
- remove_instance_variable(:@backtrace_log_level) if instance_variable_defined?( :@backtrace_log_level )
421
+
422
+ @memoized_log_level = nil
423
+ @log_level = nil
424
+ @backtrace_log_level = nil
425
+ @memoized_backtrace_log_level = nil
421
426
 
422
427
  self.name = @initialized_name
423
428
  self.path = @initialized_path_so_far ? @initialized_path_so_far.dup : []
@@ -576,6 +581,12 @@ module Catamaran
576
581
  # Create the hash of sub_loggers as needed
577
582
  @sub_loggers ||= {}
578
583
 
584
+ # These will all be set to nil as part of the reset()
585
+ # @memoized_log_level = nil
586
+ # @log_level = nil
587
+ # @backtrace_log_level = nil
588
+ # @memoized_backtrace_log_level = nil
589
+
579
590
  reset()
580
591
 
581
592
  Catamaran.debugging( "Catamaran::Logger#initialize() - I am #{self.to_s}" ) if Catamaran.debugging?
@@ -1,4 +1,4 @@
1
1
  module Catamaran
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
4
4
 
@@ -308,6 +308,36 @@ describe Catamaran do
308
308
  Catamaran.logger.Company.Product.App.smart_log_level.should == Catamaran::LogLevel::INFO
309
309
  end
310
310
 
311
+ it "should memoize the log level of an ancestor as needed" do
312
+ Catamaran.logger.log_level = Catamaran::LogLevel::ERROR
313
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_log_level ).should be_nil
314
+ Catamaran.logger.should_receive( :log_level ).once.with( {:recursive=>true} ).and_return Catamaran::LogLevel::ERROR
315
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_log_level.should == Catamaran::LogLevel::ERROR
316
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_log_level ).should == Catamaran::LogLevel::ERROR
317
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_log_level.should == Catamaran::LogLevel::ERROR
318
+ Catamaran.logger.forget_memoizations
319
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_log_level ).should be_nil
320
+ Catamaran.logger.should_receive( :log_level ).once.with( {:recursive=>true} ).and_return Catamaran::LogLevel::ERROR
321
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_log_level.should == Catamaran::LogLevel::ERROR
322
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_log_level ).should == Catamaran::LogLevel::ERROR
323
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_log_level.should == Catamaran::LogLevel::ERROR
324
+ end
325
+
326
+ it "should memoize the backtrace log level of an ancestor as needed" do
327
+ Catamaran.logger.backtrace_log_level = Catamaran::LogLevel::ERROR
328
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_backtrace_log_level ).should be_nil
329
+ Catamaran.logger.should_receive( :backtrace_log_level ).once.with( {:recursive=>true} ).and_return Catamaran::LogLevel::ERROR
330
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_backtrace_log_level.should == Catamaran::LogLevel::ERROR
331
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_backtrace_log_level ).should == Catamaran::LogLevel::ERROR
332
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_backtrace_log_level.should == Catamaran::LogLevel::ERROR
333
+ Catamaran.logger.forget_memoizations
334
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_backtrace_log_level ).should be_nil
335
+ Catamaran.logger.should_receive( :backtrace_log_level ).once.with( {:recursive=>true} ).and_return Catamaran::LogLevel::ERROR
336
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_backtrace_log_level.should == Catamaran::LogLevel::ERROR
337
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.instance_variable_get( :@memoized_backtrace_log_level ).should == Catamaran::LogLevel::ERROR
338
+ Catamaran.logger.com.mycompany.myrailsproject.app.models.smart_backtrace_log_level.should == Catamaran::LogLevel::ERROR
339
+ end
340
+
311
341
  context "when the log level is specified, the default is no longer used" do
312
342
  it "should makeuse of the specified log level rather than the inherited one" do
313
343
  initial_log_level = Catamaran.logger.smart_log_level
@@ -325,9 +355,9 @@ describe Catamaran do
325
355
  end
326
356
 
327
357
  it "should be able to handle IO log levels" do
358
+ Catamaran::LogLevel.severity_to_s( Catamaran::LogLevel::IO_LESS_CRITICAL_THAN_TRACE ).should == 'IO'
328
359
  Catamaran::LogLevel.severity_to_s( Catamaran::LogLevel::IO_LESS_CRITICAL_THAN_INFO ).should == 'IO'
329
360
  Catamaran::LogLevel.severity_to_s( Catamaran::LogLevel::IO_LESS_CRITICAL_THAN_DEBUG ).should == 'IO'
330
- Catamaran::LogLevel.severity_to_s( Catamaran::LogLevel::IO_LESS_CRITICAL_THAN_NOTICE ).should == 'IO'
331
361
  end
332
362
  end
333
363
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catamaran
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A logging utility
14
14
  email: