semantic_logger 2.19.0 → 2.20.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: 8edd7638dee098976eeee0f818ea64c213da2a1f
4
- data.tar.gz: a03fac478e80e0784e765a7c2f28c8c6b929b94b
3
+ metadata.gz: 141016c8a502a158974b0dfe589a90b5cd650826
4
+ data.tar.gz: 09cb7afdf37afe6280098b01f7257c8a21b5995e
5
5
  SHA512:
6
- metadata.gz: 9f85f11748ef85c23dbd912fa5a690d57cd50af051edaeb37014ba30ef987e9f22866b0632f457327c78f6243e88b242c2fe3cc4c46135b8b2f64c298de9961e
7
- data.tar.gz: 1b5ac351139f57b94743022465f86030a8959df41e696fdcb048b4f3f07adfa1736bc21d9f4de74c6b8e0434a5d32ee44c79b7c26df4272a0201a78da8bb017a
6
+ metadata.gz: 3f734075af2a306b37560903beb0d0003f912706f6d68446914832cbb76a404c7017dd536c587eb155309a1128ebf328719f33c727b0ca129d03d2bea8f6fa21
7
+ data.tar.gz: a96ffd5c36c47e4e7787dc53970dafe092203f6e717f6aba4289217b45e14b1e36317151dcbe2af60178e78d3266ed92f23bd3f7ba6c39d1592d5fbd37794458
@@ -29,65 +29,21 @@ module SemanticLogger
29
29
 
30
30
  def self.included(base)
31
31
  base.class_eval do
32
+ # Returns [SemanticLogger::Logger] class level logger
32
33
  def self.logger
33
34
  @semantic_logger ||= SemanticLogger[self]
34
35
  end
35
- end
36
- end
37
36
 
38
- # Also make the logger available as an instance method MixIn
39
- # The class logger can be replaced using an instance specific #logger= below
40
- def logger
41
- @semantic_logger ||= self.class.logger
42
- end
37
+ # Returns [SemanticLogger::Logger] instance level logger
38
+ def logger
39
+ @semantic_logger ||= self.class.logger
40
+ end
43
41
 
44
- # Set instance specific logger
45
- #
46
- # By default instances of the class will use the class logger. Sometimes it
47
- # is useful to be able to add instance specific logging data to the class name.
48
- #
49
- # For example, server or host_name that the class instance is using.
50
- #
51
- # Example:
52
- # require 'semantic_logger'
53
- # SemanticLogger.default_level = :debug
54
- # SemanticLogger.add_appender(STDOUT)
55
- #
56
- # class MyClass
57
- # include SemanticLogger::Loggable
58
- #
59
- # def self.my_name=(my_name)
60
- # # Use class level logger that only logs class name
61
- # logger.info "My name is changed to #{my_name}"
62
- #
63
- # @@my_name = my_name
64
- # end
65
- #
66
- # def initialize(host_name)
67
- # # Add host_name to every log entry in this logging instance
68
- # self.logger = SemanticLogger["#{self.class.name} [#{host_name}]"]
69
- #
70
- # logger.info "Started server"
71
- # end
72
- #
73
- # def check
74
- # logger.debug "Checking..."
75
- # end
76
- # end
77
- #
78
- # MyClass.my_name = "Joe"
79
- #
80
- # mine = MyClass.new('server.com')
81
- # mine.check
82
- #
83
- # # Generates the following log output:
84
- #
85
- # 2013-04-02 15:08:42.368574 I [37279:70198560687720] MyClass -- My name is changed to Joe
86
- # 2013-04-02 15:08:42.369934 I [37279:70198560687720] MyClass [server.com] -- Started server
87
- # 2013-04-02 15:08:42.371171 D [37279:70198560687720] MyClass [server.com] -- Checking...
88
- #
89
- def logger=(logger)
90
- @semantic_logger = logger
42
+ # Replace instance level logger
43
+ def logger=(logger)
44
+ @semantic_logger = logger
45
+ end
46
+ end
91
47
  end
92
48
 
93
49
  end
@@ -1,3 +1,3 @@
1
1
  module SemanticLogger #:nodoc
2
- VERSION = '2.19.0'
2
+ VERSION = '2.20.0'
3
3
  end
@@ -8,11 +8,25 @@ end
8
8
  # Unit Test for SemanticLogger::Appender::File
9
9
  #
10
10
  class AppenderFileTest < Minitest::Test
11
+ module Perform
12
+ def perform
13
+ logger.info 'perform'
14
+ end
15
+ end
16
+
11
17
  class Base
12
18
  include SemanticLogger::Loggable
19
+ include Perform
20
+ end
21
+
22
+ module Process
23
+ def process
24
+ logger.info 'process'
25
+ end
13
26
  end
14
27
 
15
28
  class Subclass < Base
29
+ include Process
16
30
  end
17
31
 
18
32
  describe SemanticLogger::Loggable do
@@ -36,6 +50,26 @@ class AppenderFileTest < Minitest::Test
36
50
  refute_equal child_logger, base.logger
37
51
  assert_equal child_logger.object_id, subclass.logger.object_id
38
52
  end
53
+
54
+ it 'should allow mixins to call parent logger' do
55
+ base = Base.new
56
+ base.perform
57
+ called = false
58
+ Base.logger.stub(:info, -> description { called = true if description == 'perform' }) do
59
+ base.perform
60
+ end
61
+ assert called, 'Did not call the correct logger'
62
+ end
63
+
64
+ it 'should allow child mixins to call parent logger' do
65
+ subclass = Subclass.new
66
+ subclass.process
67
+ called = false
68
+ Subclass.logger.stub(:info, -> description { called = true if description == 'process' }) do
69
+ subclass.process
70
+ end
71
+ assert called, 'Did not call the correct logger'
72
+ end
39
73
  end
40
74
 
41
75
  describe 'logger' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.0
4
+ version: 2.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-05 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby