semantic_logger 2.1.0 → 2.2.0

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: 4f813c09eacb56b09335612d00c499738d0ee84c
4
- data.tar.gz: ad074b21691cac740d8c0c6272d4263f4c41421a
3
+ metadata.gz: cd64eb04f0be456dd95ec325d6ac00af3dba49c1
4
+ data.tar.gz: 2d48aa4423c72c71ba7cf42e370d4dd5b21adc47
5
5
  SHA512:
6
- metadata.gz: 1211db34d7bc22f0f6c319b636a67decd6a23717568778b7f77413826b4940a3e1c699685e0890cb64c54e5e65a9d677a7923e54935a5203de76ef671a9cb0bd
7
- data.tar.gz: d940844e714486e76be5e5e6b839c3ccaedc66566781b2b8a9d51c09eb4b077652e7b2db0bce1004a3b41098143d9cd263aa6eb16b64a968b1278ef1455fb4d9
6
+ metadata.gz: 6dc6dca8b8c4553acedbcc639f5daaeee367043816d23ad6816a0be9360b8529df18a3145fb0717b06a8964d1028bdccf61117e6edcfe5a1f719882cb7058c0b
7
+ data.tar.gz: e552b8b33ef2b967c3d18321cb8f1dd9e2d3173a57eaef32f3e25261767b0864ba6735d54e12a4ceb3dc0e7038077f10727fc72eb049130336b04621bcda7d2b
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.13)
5
+ i18n (= 0.6.1)
6
+ multi_json (~> 1.0)
7
+ atomic (1.1.8)
8
+ bourne (1.4.0)
9
+ mocha (~> 0.13.2)
10
+ bson (1.8.5)
11
+ bson_ext (1.8.5)
12
+ bson (~> 1.8.5)
13
+ i18n (0.6.1)
14
+ metaclass (0.0.1)
15
+ mocha (0.13.3)
16
+ metaclass (~> 0.0.1)
17
+ mongo (1.8.5)
18
+ bson (~> 1.8.5)
19
+ multi_json (1.7.2)
20
+ shoulda (3.4.0)
21
+ shoulda-context (~> 1.0, >= 1.0.1)
22
+ shoulda-matchers (~> 1.0, >= 1.4.1)
23
+ shoulda-context (1.1.1)
24
+ shoulda-matchers (1.5.6)
25
+ activesupport (>= 3.0.0)
26
+ bourne (~> 1.3)
27
+ sync_attr (1.0.0)
28
+ thread_safe (0.1.0)
29
+ atomic
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bson_ext
36
+ mongo
37
+ shoulda
38
+ sync_attr
39
+ thread_safe
data/README.md CHANGED
@@ -589,6 +589,44 @@ level_index [Integer]
589
589
 
590
590
  * Internal use only. Index of the log level
591
591
 
592
+ #### Mixing Logging Levels
593
+
594
+ It is sometimes useful to log a subset of the log messages to a separate file
595
+ or appender. For example, log :error and :fatal level messages to a special
596
+ error file.
597
+
598
+ Below is a stand-alone example that better shows this behavior:
599
+
600
+ ```ruby
601
+ require 'semantic_logger'
602
+
603
+ # Set default log level for new logger instances
604
+ SemanticLogger.default_level = :info
605
+
606
+ # Log all warning messages and above to warnings.log
607
+ SemanticLogger.add_appender('log/warnings.log', :warn)
608
+
609
+ # Log all trace messages and above to trace.log
610
+ SemanticLogger.add_appender('log/trace.log', :trace)
611
+
612
+ logger = SemanticLogger['MyClass']
613
+ logger.level = :trace
614
+ logger.trace "This is a trace message"
615
+ logger.info "This is an info message"
616
+ logger.warn "This is a warning message"
617
+ ```
618
+
619
+ The output is as follows:
620
+ ```bash
621
+ ==> trace.log <==
622
+ 2013-08-02 14:15:56.733532 T [35669:70176909690580] MyClass -- This is a trace message
623
+ 2013-08-02 14:15:56.734273 I [35669:70176909690580] MyClass -- This is an info message
624
+ 2013-08-02 14:15:56.735273 W [35669:70176909690580] MyClass -- This is a warning message
625
+
626
+ ==> warnings.log <==
627
+ 2013-08-02 14:15:56.735273 W [35669:70176909690580] MyClass -- This is a warning message
628
+ ```
629
+
592
630
  #### Custom Formatters
593
631
 
594
632
  The formatting for each appender can be replaced with custom code. To replace the
@@ -147,19 +147,16 @@ module SemanticLogger
147
147
  # Add the supplied tags to the list of tags to log for this thread whilst
148
148
  # the supplied block is active
149
149
  # Returns nil if no tags are currently set
150
- def with_tags(*tags)
151
- current_tags = self.tags
152
- # Check for nil tags
153
- if tags
154
- Thread.current[:semantic_logger_tags] = current_tags ? current_tags + tags : tags
155
- end
150
+ # To support: ActiveSupport::TaggedLogging V3 and above
151
+ def tagged(*tags)
152
+ push_tags(*tags)
156
153
  yield
157
154
  ensure
158
- Thread.current[:semantic_logger_tags] = current_tags
155
+ pop_tags(tags.size)
159
156
  end
160
157
 
161
- # Add support for the ActiveSupport::TaggedLogging
162
- alias_method :tagged, :with_tags
158
+ # Previous method for supplying tags
159
+ alias_method :with_tags, :tagged
163
160
 
164
161
  # Returns [Array] of [String] tags currently active for this thread
165
162
  # Returns nil if no tags are set
@@ -167,6 +164,21 @@ module SemanticLogger
167
164
  Thread.current[:semantic_logger_tags]
168
165
  end
169
166
 
167
+ # Add tags to the current scope
168
+ # To support: ActiveSupport::TaggedLogging V4 and above
169
+ def push_tags *tags
170
+ # Check for nil tags
171
+ Thread.current[:semantic_logger_tags] = (self.tags || []) + tags if tags
172
+ end
173
+
174
+ # Remove specified number of tags from the current tag list
175
+ # To support: ActiveSupport::TaggedLogging V4 and above
176
+ def pop_tags(quantity)
177
+ if tags = self.tags
178
+ Thread.current[:semantic_logger_tags] = tags.pop(quantity)
179
+ end
180
+ end
181
+
170
182
  # Thread specific context information to be logged with every log entry
171
183
  #
172
184
  # Add a payload to all log calls on This Thread within the supplied block
@@ -5,6 +5,10 @@ require 'thread_safe'
5
5
  module SemanticLogger
6
6
  class Logger < Base
7
7
 
8
+ # Add unused formatter to support Rails 4 logging
9
+ # Formatters must be set at the appender level, not at the logger level
10
+ attr_accessor :formatter
11
+
8
12
  # Returns a Logger instance
9
13
  #
10
14
  # Return the logger for a specific class, supports class specific log levels
@@ -1,3 +1,3 @@
1
1
  module SemanticLogger #:nodoc
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
data/others.txt ADDED
@@ -0,0 +1,5 @@
1
+ logback
2
+ logging
3
+ log4r
4
+ central_logger
5
+ whoops
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.1.0
4
+ version: 2.2.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: 2013-04-03 00:00:00.000000000 Z
11
+ date: 2013-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sync_attr
@@ -47,6 +47,7 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - Gemfile
50
+ - Gemfile.lock
50
51
  - LICENSE.txt
51
52
  - README.md
52
53
  - Rakefile
@@ -60,6 +61,7 @@ files:
60
61
  - lib/semantic_logger/logger.rb
61
62
  - lib/semantic_logger/semantic_logger.rb
62
63
  - lib/semantic_logger/version.rb
64
+ - others.txt
63
65
  - test/appender_file_test.rb
64
66
  - test/appender_mongodb_test.rb
65
67
  - test/appender_wrapper_test.rb
@@ -86,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
88
  version: '0'
87
89
  requirements: []
88
90
  rubyforge_project:
89
- rubygems_version: 2.0.2
91
+ rubygems_version: 2.0.3
90
92
  signing_key:
91
93
  specification_version: 4
92
94
  summary: Improved logging for Ruby