hatchet 0.0.13 → 0.0.14
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.
- data/lib/hatchet/hatchet_logger.rb +18 -4
- data/lib/hatchet/level_manager.rb +3 -0
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet.rb +1 -1
- data/spec/logger_spec.rb +8 -4
- metadata +2 -2
@@ -43,12 +43,13 @@ module Hatchet
|
|
43
43
|
|
44
44
|
# Internal: Creates a new logger.
|
45
45
|
#
|
46
|
-
# host
|
47
|
-
#
|
46
|
+
# host - The object the logger gains its context from.
|
47
|
+
# configuration - The configuration of Hatchet.
|
48
48
|
#
|
49
|
-
def initialize(host,
|
49
|
+
def initialize(host, configuration)
|
50
50
|
@context = context host
|
51
|
-
@
|
51
|
+
@configuration = configuration
|
52
|
+
@appenders = configuration.appenders
|
52
53
|
end
|
53
54
|
|
54
55
|
[:debug, :info, :warn, :error, :fatal].each do |level|
|
@@ -86,6 +87,19 @@ module Hatchet
|
|
86
87
|
|
87
88
|
end
|
88
89
|
|
90
|
+
# Public: Set the lowest level of message to log by default.
|
91
|
+
#
|
92
|
+
# level - The lowest level of message to log by default.
|
93
|
+
#
|
94
|
+
# The use of this method is not recommended as it affects the performance of
|
95
|
+
# the logging. It is only provided for compatibility.
|
96
|
+
#
|
97
|
+
# Returns nothing.
|
98
|
+
#
|
99
|
+
def level=(level)
|
100
|
+
@configuration.level = level
|
101
|
+
end
|
102
|
+
|
89
103
|
private
|
90
104
|
|
91
105
|
# Private: Adds a message to each appender at the specified level.
|
@@ -22,6 +22,7 @@ module Hatchet
|
|
22
22
|
# levels - The Hash to use as the log level configuration.
|
23
23
|
#
|
24
24
|
# Returns nothing.
|
25
|
+
#
|
25
26
|
def levels=(levels)
|
26
27
|
@levels = levels
|
27
28
|
clear_levels_cache!
|
@@ -36,6 +37,7 @@ module Hatchet
|
|
36
37
|
# not been specified.
|
37
38
|
#
|
38
39
|
# Returns nothing.
|
40
|
+
#
|
39
41
|
def level(level, context = nil)
|
40
42
|
context = context.to_s unless context.nil?
|
41
43
|
self.levels[context] = level
|
@@ -47,6 +49,7 @@ module Hatchet
|
|
47
49
|
# level - The lowest level of message to log by default.
|
48
50
|
#
|
49
51
|
# Returns nothing.
|
52
|
+
#
|
50
53
|
def level=(level)
|
51
54
|
self.level(level)
|
52
55
|
end
|
data/lib/hatchet/version.rb
CHANGED
data/lib/hatchet.rb
CHANGED
@@ -62,7 +62,7 @@ module Hatchet
|
|
62
62
|
# Returns a HatchetLogger for the object.
|
63
63
|
#
|
64
64
|
def logger
|
65
|
-
@_hatchet_logger ||= HatchetLogger.new self, Hatchet.
|
65
|
+
@_hatchet_logger ||= HatchetLogger.new self, Hatchet.configuration
|
66
66
|
end
|
67
67
|
|
68
68
|
# Public: Returns a HatchetLogger for the object.
|
data/spec/logger_spec.rb
CHANGED
@@ -4,10 +4,14 @@ require_relative 'spec_helper'
|
|
4
4
|
|
5
5
|
describe HatchetLogger do
|
6
6
|
let(:disabled_appender) { DisabledAppender.new }
|
7
|
-
let(:appender)
|
8
|
-
let(:appenders)
|
9
|
-
let(:
|
10
|
-
let(:
|
7
|
+
let(:appender) { StoringAppender.new :debug }
|
8
|
+
let(:appenders) { [appender, disabled_appender] }
|
9
|
+
let(:configuration) { Configuration.new }
|
10
|
+
let(:context) { Context::Class.new }
|
11
|
+
let(:subject) do
|
12
|
+
configuration.appenders.push(*appenders)
|
13
|
+
HatchetLogger.new context, configuration
|
14
|
+
end
|
11
15
|
|
12
16
|
ALL_LEVELS.each do |level|
|
13
17
|
describe "receiving #{level} messages" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hatchet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.8.
|
68
|
+
rubygems_version: 1.8.17
|
69
69
|
signing_key:
|
70
70
|
specification_version: 3
|
71
71
|
summary: Logging library that provides the ability to add class/module specific filters
|