lumber 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/CHANGELOG +13 -0
  2. data/README.rdoc +7 -4
  3. data/VERSION +1 -1
  4. data/lib/lumber/lumber.rb +19 -3
  5. metadata +3 -2
data/CHANGELOG ADDED
@@ -0,0 +1,13 @@
1
+ 0.0.2
2
+ -----
3
+
4
+ changelogs <a68ba93> [Matt Conway]
5
+ changelogs <380cbf3> [Matt Conway]
6
+ add jeweller gemcutter support <da96329> [Matt Conway]
7
+ fix spelling on hierarchy, handle missing loggers in class hierarchy <1e4e3c0> [Matt Conway]
8
+
9
+ 0.0.1
10
+ -----
11
+
12
+ Initial Version
13
+
data/README.rdoc CHANGED
@@ -13,14 +13,17 @@ to config/environment.rb:
13
13
  require 'lumber'
14
14
  Lumber.init()
15
15
 
16
+ # If you really want all classes to have a logger
17
+ # Lumber.setup_logger_hierarchy(Object, "root::object")
18
+
16
19
  # Inside the block for Rails::Initializer.run
17
20
  #
18
21
  config.after_initialize do
19
- # setup log4r heirarchy - these need to happen after frameworks
22
+ # setup log4r hierarchy - these need to happen after frameworks
20
23
  # are loaded, but before subclasses get defined
21
- Lumber.setup_logger_heirarchy(ActiveRecord::Base, "rails::models")
22
- Lumber.setup_logger_heirarchy(ActionController::Base, "rails::controllers")
23
- Lumber.setup_logger_heirarchy(ActionMailer::Base, "rails::mailers")
24
+ Lumber.setup_logger_hierarchy(ActiveRecord::Base, "rails::models")
25
+ Lumber.setup_logger_hierarchy(ActionController::Base, "rails::controllers")
26
+ Lumber.setup_logger_hierarchy(ActionMailer::Base, "rails::mailers")
24
27
  end
25
28
 
26
29
  If you want to change the log level for a different environment, add a line like below to the config/environments/<env>.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/lumber/lumber.rb CHANGED
@@ -41,11 +41,11 @@ module Lumber
41
41
  # Makes :logger exist independently for subclasses and sets that logger
42
42
  # to one that inherits from base_class for each subclass as its created.
43
43
  # This allows you to have a finer level of control over logging, for example,
44
- # put just a single class, or heirarchy of classes, into debug log level
44
+ # put just a single class, or hierarchy of classes, into debug log level
45
45
  #
46
46
  # for example:
47
47
  #
48
- # Lumber.setup_logger_heirarchy(ActiveRecord::Base, "rails::models")
48
+ # Lumber.setup_logger_hierarchy(ActiveRecord::Base, "rails::models")
49
49
  #
50
50
  # causes all models that get created to have a log4r logger named
51
51
  # "rails::models::<class_name>". This class can individually be
@@ -53,7 +53,7 @@ module Lumber
53
53
  # output will include "<class_name>" on every log from this class
54
54
  # so that you can tell where a log statement came from
55
55
  #
56
- def self.setup_logger_heirarchy(base_class, parent_fullname)
56
+ def self.setup_logger_hierarchy(base_class, parent_fullname)
57
57
  base_class.class_eval do
58
58
  class_inheritable_accessor :logger
59
59
  self.logger = Log4r::Logger.new(parent_fullname)
@@ -61,6 +61,22 @@ module Lumber
61
61
  class << self
62
62
  def inherited_with_lumber_log4r(subclass)
63
63
  inherited_without_lumber_log4r(subclass)
64
+ # p "#{self} -> #{subclass} -> #{self.logger}"
65
+
66
+ # Look up the class hierarchy for a useable logger
67
+ # A class may have a nil logger if it was created
68
+ # before we add logger/inheritance to its superclas,
69
+ # e.g. Object/Exception - something tries to subclass
70
+ # Exception after we added lumber_inherited to Object,
71
+ # but Exception was defined before we added lumber_inherited
72
+ while self.logger.nil?
73
+ next_class = (next_class ||self).superclass
74
+ if next_class.nil?
75
+ self.logger = Log4r::Logger.root
76
+ else
77
+ self.logger = next_class.logger
78
+ end
79
+ end
64
80
  subclass.logger = Log4r::Logger.new("#{logger.fullname}::#{subclass.name}")
65
81
  end
66
82
  alias_method_chain :inherited, :lumber_log4r
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-03 00:00:00 -04:00
12
+ date: 2009-10-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,7 @@ extra_rdoc_files:
42
42
  - LICENSE
43
43
  - README.rdoc
44
44
  files:
45
+ - CHANGELOG
45
46
  - LICENSE
46
47
  - README.rdoc
47
48
  - TODO