catamaran 0.8.1 → 0.9.0

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: 410f6cab582f4a6bae572cb402f8418de8ba747a
4
- data.tar.gz: 0a3d19f6bf7fa91ab2ab2adc975ef9c97383a6c1
3
+ metadata.gz: 070bb5224a0412112c13ca5981859b8d201be22d
4
+ data.tar.gz: 2192f55d66d64d284a20bc409a1c0a2cc92c795e
5
5
  SHA512:
6
- metadata.gz: 6f0404c71937b1c5a498dec0c08046a650f1aa12f5463e6394935bced82fb16304d7470c8c1816b74b07740dd6d6dd44f103c5cbdf78be8dc2e959f37d608718
7
- data.tar.gz: 530fe5faf02e4ff3d6b411ddbb9b1a420e4589e92529f03f8c0762141d84337e7e92af444be26b13b677e79ce7c5f2a32ee8d3b0f3243d7f1738ab14620082aa
6
+ metadata.gz: b809ca0a2dcf06b23aa5eddb66820781ed28c978da4e16a9d45e4e2d3f0fa250f5074fa4e746405211e3eea7d46599193d7e861769add0b858bdb081fa3cae8e
7
+ data.tar.gz: 1fc5c6ff9a835959cc43833e0c39fa250c32188c8eba73b89fe5d41738e078c972d10362e0f795b3307604b43f533e575e064e91b9e194c3251818a8850812cc
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.8.1'
9
+ gem 'catamaran', '~> 0.9.0'
10
10
 
11
11
  Rails-related setup:
12
12
 
@@ -20,14 +20,21 @@ Ruby Quickstart
20
20
  require 'catamaran'
21
21
 
22
22
  class FirstRubyDemo
23
- LOGGER = Catamaran.logger( "FirstRubyDemo" )
23
+ LOGGER = Catamaran.logger( "com.mytld.FirstRubyDemo" )
24
24
  # or equivalently:
25
- # LOGGER = Catamaran.logger.FirstRubyDemo
25
+ # LOGGER = Catamaran.logger.com.mytld.FirstRubyDemo
26
26
 
27
27
  def run
28
- LOGGER.notice( "Note that NOTICE messages are captured by default" ) if LOGGER.notice?
29
- LOGGER.info( "Note that INFO messages are NOT captured by default" ) if LOGGER.info?
30
- LOGGER.debug( "Note that DEBUG messages are NOT captured by default" ) if LOGGER.debug?
28
+ # Disabled by default
29
+ LOGGER.trace( "TRACE logs are NOT captured by default" ) if LOGGER.trace?
30
+ LOGGER.debug( "DEBUG logs are NOT captured by default" ) if LOGGER.debug?
31
+ LOGGER.info( "INFO logs are NOT captured by default" ) if LOGGER.info?
32
+
33
+ # Enabled by default
34
+ LOGGER.notice( "NOTICE logs are captured by default" )
35
+ LOGGER.warn( "WARN logs are captured by default" )
36
+ LOGGER.error( "ERROR logs are captured by default" )
37
+ LOGGER.severe( "SEVERE logs are captured by default" )
31
38
  end
32
39
  end
33
40
 
@@ -36,7 +43,12 @@ FirstRubyDemo.new.run
36
43
 
37
44
  And the output
38
45
 
39
- NOTICE pid-2729 [2013-12-23 19:35:35:732] FirstRubyDemo - Note that NOTICE messages are getting captured by default
46
+ ```
47
+ NOTICE pid-23773 [2014-01-01 13:09:47:551] com.mytld.FirstRubyDemo - NOTICE logs are captured by default
48
+ WARN pid-23773 [2014-01-01 13:09:47:551] com.mytld.FirstRubyDemo - WARN logs are captured by default
49
+ ERROR pid-23773 [2014-01-01 13:09:47:551] com.mytld.FirstRubyDemo - ERROR logs are captured by default
50
+ SEVERE pid-23773 [2014-01-01 13:09:47:551] com.mytld.FirstRubyDemo - SEVERE logs are captured by default
51
+ ```
40
52
 
41
53
 
42
54
  Rails Quickstart
@@ -44,7 +56,7 @@ Rails Quickstart
44
56
 
45
57
  ```ruby
46
58
  class PagesController < ApplicationController
47
- LOGGER = Catamaran.logger.com.mycompany.myrailsapp.app.controllers.PagesController
59
+ LOGGER = Catamaran.logger.com.mytld.myrailsapp.app.controllers.PagesController
48
60
 
49
61
  def index
50
62
  LOGGER.debug "Entering with params = #{params}" if LOGGER.debug?
@@ -55,7 +67,8 @@ end
55
67
  Load the `index` page and check out your `development.log` file
56
68
 
57
69
  ### Sample log entry (in your development.log file)
58
- DEBUG pid-86000 [2013-12-17 17:26:39:176] pany.myrailsapp.app.controllers.PagesController - Entering with params = {"controller"=>"pages", "action"=>"index"} (`/myrailsapp/app/controllers/pages_controller.rb:7`:in `index`)
70
+
71
+ DEBUG pid-86000 [2013-12-17 17:26:39:176] ytld.myrailsapp.app.controllers.PagesController - Entering with params = {"controller"=>"pages", "action"=>"index"} (`/myrailsapp/app/controllers/pages_controller.rb:7`:in `index`)
59
72
 
60
73
  Log Levels
61
74
  ----------
@@ -82,7 +95,7 @@ class SecondRubyDemo
82
95
  end
83
96
 
84
97
  class ThirdRubyDemo
85
- LOGGER = Catamaran.logger( "com.mycompany.ThirdRubyDemo", { :class => name(), :file => __FILE__ } )
98
+ LOGGER = Catamaran.logger( "com.mytld.ThirdRubyDemo", { :class => name(), :file => __FILE__ } )
86
99
 
87
100
  def run
88
101
  LOGGER.warn( "Sample WARN statement", { :line => __LINE__, :method => 'run' } )
@@ -98,9 +111,9 @@ ThirdRubyDemo.new.run
98
111
  And the output
99
112
 
100
113
  INFO pid-5973 [2013-12-27 17:18:09:115] - Sample INFO statement (catamaran_ruby_demos.rb:12:in `SecondRubyDemo.run')
101
- WARN pid-5973 [2013-12-27 17:18:09:115] com.mycompany.ThirdRubyDemo - Sample WARN statement (catamaran_ruby_demos.rb:20:in `ThirdRubyDemo.run')
102
- WARN pid-5973 [2013-12-27 17:18:09:115] com.mycompany.ThirdRubyDemo - Sample WARN statement with backtrace option (catamaran_ruby_demos.rb:21:in `ThirdRubyDemo.run')
103
- ERROR pid-5973 [2013-12-27 17:18:09:115] com.mycompany.ThirdRubyDemo - Sample ERROR statement with backtrace option (catamaran_ruby_demos.rb:22:in `ThirdRubyDemo.run') from:
114
+ WARN pid-5973 [2013-12-27 17:18:09:115] com.mytld.ThirdRubyDemo - Sample WARN statement (catamaran_ruby_demos.rb:20:in `ThirdRubyDemo.run')
115
+ WARN pid-5973 [2013-12-27 17:18:09:115] com.mytld.ThirdRubyDemo - Sample WARN statement with backtrace option (catamaran_ruby_demos.rb:21:in `ThirdRubyDemo.run')
116
+ ERROR pid-5973 [2013-12-27 17:18:09:115] com.mytld.ThirdRubyDemo - Sample ERROR statement with backtrace option (catamaran_ruby_demos.rb:22:in `ThirdRubyDemo.run') from:
104
117
  catamaran_ruby_demos.rb:22:in `run'
105
118
  catamaran_ruby_demos.rb:27:in `<main>'
106
119
 
@@ -55,8 +55,11 @@ module Catamaran
55
55
  'IO'
56
56
  when IO_LESS_CRITICAL_THAN_DEBUG
57
57
  'IO'
58
+ when IO_LESS_CRITICAL_THAN_NOTICE
59
+ 'IO'
58
60
  else
59
- 'UNKNOWN'
61
+ # Unknown
62
+ ''
60
63
  end
61
64
  end
62
65
 
@@ -12,12 +12,15 @@ module Catamaran
12
12
 
13
13
  def log_level( opts = {} )
14
14
  if instance_variable_defined?( :@log_level ) && @log_level
15
- retval = @log_level
15
+ # Implicit return
16
+ @log_level
16
17
  elsif self.parent.nil?
17
18
  # No parent means this logger(self) is the root logger. So use the default log level
18
- retval = Catamaran::LogLevel::NOTICE
19
+
20
+ # Implicit return
21
+ Catamaran::LogLevel::NOTICE
19
22
  else
20
- recursive = opts[:recursive]
23
+ recursive = ( opts[:recursive] == true || opts[:be_populated] == true )
21
24
  if recursive == true
22
25
 
23
26
  # Remember the log level we found so we don't have to recursively look for it ever time
@@ -25,15 +28,15 @@ module Catamaran
25
28
  @memoized_log_level = parent.log_level( opts ) if parent
26
29
  end
27
30
 
28
- retval = @memoized_log_level
31
+ # Implicit return
32
+ @memoized_log_level
29
33
  else
30
34
  Catamaran.debugging( "Catamaran::Logger#log_level() - non-recrusive request for log level. And log level is nil. This shouldn't happen too often." ) if Catamaran.debugging?
31
- retval = nil
35
+
36
+ # Implicit return
37
+ nil
32
38
  end
33
39
  end
34
-
35
- # Implicit return
36
- retval
37
40
  end
38
41
 
39
42
  ##
@@ -137,7 +140,7 @@ module Catamaran
137
140
  # Is trace-level logging currently enabled?
138
141
 
139
142
  def trace?
140
- if self.smart_log_level() <= LogLevel::TRACE
143
+ if self.log_level( { :be_populated => true } ) <= LogLevel::TRACE
141
144
  true
142
145
  else
143
146
  false
@@ -145,7 +148,8 @@ module Catamaran
145
148
  end
146
149
 
147
150
  def trace( msg, opts = nil )
148
- if trace?
151
+ # Duplicated the logic from trace? for performance considerations
152
+ if self.log_level( { :be_populated => true } ) <= LogLevel::TRACE
149
153
  log( LogLevel::TRACE, msg, opts )
150
154
  end
151
155
  end
@@ -154,7 +158,7 @@ module Catamaran
154
158
  # Is debug-level logging currently enabled?
155
159
 
156
160
  def debug?
157
- if self.smart_log_level() <= LogLevel::DEBUG
161
+ if self.log_level( { :be_populated => true } ) <= LogLevel::DEBUG
158
162
  true
159
163
  else
160
164
  false
@@ -162,7 +166,8 @@ module Catamaran
162
166
  end
163
167
 
164
168
  def debug( msg, opts = nil )
165
- if debug?
169
+ # Duplicated the logic from debug? for performance considerations
170
+ if self.log_level( { :be_populated => true } ) <= LogLevel::DEBUG
166
171
  log( LogLevel::DEBUG, msg, opts )
167
172
  end
168
173
  end
@@ -172,7 +177,7 @@ module Catamaran
172
177
  # Is io-level logging currently enabled?
173
178
 
174
179
  def io?
175
- if self.smart_log_level() <= LogLevel::IO
180
+ if self.log_level( { :be_populated => true } ) <= LogLevel::IO
176
181
  true
177
182
  else
178
183
  false
@@ -180,7 +185,8 @@ module Catamaran
180
185
  end
181
186
 
182
187
  def io( msg, opts = nil )
183
- if io?
188
+ # Duplicated the logic from io? for performance considerations
189
+ if self.log_level( { :be_populated => true } ) <= LogLevel::IO
184
190
  log( LogLevel::IO, msg, opts )
185
191
  end
186
192
  end
@@ -189,7 +195,7 @@ module Catamaran
189
195
  # Is info-level logging currently enabled?
190
196
 
191
197
  def info?
192
- if self.smart_log_level() <= LogLevel::INFO
198
+ if self.log_level( { :be_populated => true } ) <= LogLevel::INFO
193
199
  true
194
200
  else
195
201
  false
@@ -197,7 +203,8 @@ module Catamaran
197
203
  end
198
204
 
199
205
  def info( msg, opts = nil )
200
- if info?
206
+ # Duplicated the logic from info? for performance considerations
207
+ if self.log_level( { :be_populated => true } ) <= LogLevel::INFO
201
208
  log( LogLevel::INFO, msg, opts )
202
209
  end
203
210
  end
@@ -206,7 +213,7 @@ module Catamaran
206
213
  # Is notice-level logging currently enabled?
207
214
 
208
215
  def notice?
209
- if self.smart_log_level() <= LogLevel::NOTICE
216
+ if self.log_level( { :be_populated => true } ) <= LogLevel::NOTICE
210
217
  true
211
218
  else
212
219
  false
@@ -214,7 +221,8 @@ module Catamaran
214
221
  end
215
222
 
216
223
  def notice( msg, opts = nil )
217
- if notice?
224
+ # Duplicated the logic from notice? for performance considerations
225
+ if self.log_level( { :be_populated => true } ) <= LogLevel::NOTICE
218
226
  log( LogLevel::NOTICE, msg, opts )
219
227
  end
220
228
  end
@@ -223,7 +231,7 @@ module Catamaran
223
231
  # Is warn-level logging currently enabled?
224
232
 
225
233
  def warn?
226
- if self.smart_log_level() <= LogLevel::WARN
234
+ if self.log_level( { :be_populated => true } ) <= LogLevel::WARN
227
235
  true
228
236
  else
229
237
  false
@@ -231,7 +239,8 @@ module Catamaran
231
239
  end
232
240
 
233
241
  def warn( msg, opts = nil )
234
- if warn?
242
+ # Duplicated the logic from warn? for performance considerations
243
+ if self.log_level( { :be_populated => true } ) <= LogLevel::WARN
235
244
  log( LogLevel::WARN, msg, opts )
236
245
  end
237
246
  end
@@ -240,7 +249,7 @@ module Catamaran
240
249
  # Is error-level logging currently enabled?
241
250
 
242
251
  def error?
243
- if self.smart_log_level() <= LogLevel::ERROR
252
+ if self.log_level( { :be_populated => true } ) <= LogLevel::ERROR
244
253
  true
245
254
  else
246
255
  false
@@ -248,7 +257,8 @@ module Catamaran
248
257
  end
249
258
 
250
259
  def error( msg, opts = nil )
251
- if error?
260
+ # Duplicated the logic from error? for performance considerations
261
+ if self.log_level( { :be_populated => true } ) <= LogLevel::ERROR
252
262
  log( LogLevel::ERROR, msg, opts )
253
263
  end
254
264
  end
@@ -257,7 +267,7 @@ module Catamaran
257
267
  # Is severe-level logging currently enabled?
258
268
 
259
269
  def severe?
260
- if self.smart_log_level() <= LogLevel::SEVERE
270
+ if self.log_level( { :be_populated => true } ) <= LogLevel::SEVERE
261
271
  true
262
272
  else
263
273
  false
@@ -265,7 +275,8 @@ module Catamaran
265
275
  end
266
276
 
267
277
  def severe( msg, opts = nil )
268
- if severe?
278
+ # Duplicated the logic from severe? for performance considerations
279
+ if self.log_level( { :be_populated => true } ) <= LogLevel::SEVERE
269
280
  log( LogLevel::SEVERE, msg, opts )
270
281
  end
271
282
  end
@@ -1,4 +1,4 @@
1
1
  module Catamaran
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
4
4
 
@@ -327,6 +327,7 @@ describe Catamaran do
327
327
  it "should be able to handle IO log levels" do
328
328
  Catamaran::LogLevel.severity_to_s( Catamaran::LogLevel::IO_LESS_CRITICAL_THAN_INFO ).should == 'IO'
329
329
  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'
330
331
  end
331
332
  end
332
333
  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.8.1
4
+ version: 0.9.0
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-01 00:00:00.000000000 Z
11
+ date: 2014-01-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A logging utility
14
14
  email: