hatchet 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,16 @@ module Hatchet
41
41
  #
42
42
  class HatchetLogger
43
43
 
44
+ # Internal: Map from standard library levels to Symbols.
45
+ #
46
+ STANDARD_TO_SYMBOL = {
47
+ Logger::DEBUG => :debug,
48
+ Logger::INFO => :info,
49
+ Logger::WARN => :warn,
50
+ Logger::ERROR => :error,
51
+ Logger::FATAL => :fatal
52
+ }
53
+
44
54
  # Internal: Creates a new logger.
45
55
  #
46
56
  # host - The object the logger gains its context from.
@@ -87,6 +97,12 @@ module Hatchet
87
97
 
88
98
  end
89
99
 
100
+ # Public: Returns the default level of the logger's configuration.
101
+ #
102
+ def level
103
+ @configuration.default_level
104
+ end
105
+
90
106
  # Public: Set the lowest level of message to log by default.
91
107
  #
92
108
  # level - The lowest level of message to log by default.
@@ -97,7 +113,14 @@ module Hatchet
97
113
  # Returns nothing.
98
114
  #
99
115
  def level=(level)
100
- @configuration.level = level
116
+ level = case level
117
+ when Symbol
118
+ level
119
+ else
120
+ STANDARD_TO_SYMBOL[level] || :info
121
+ end
122
+
123
+ @configuration.level level
101
124
  end
102
125
 
103
126
  private
@@ -44,14 +44,10 @@ module Hatchet
44
44
  clear_levels_cache!
45
45
  end
46
46
 
47
- # Public: Set the lowest level of message to log by default.
47
+ # Internal: Returns the default level of the configuration.
48
48
  #
49
- # level - The lowest level of message to log by default.
50
- #
51
- # Returns nothing.
52
- #
53
- def level=(level)
54
- self.level(level)
49
+ def default_level
50
+ self.levels[nil]
55
51
  end
56
52
 
57
53
  # Internal: Returns true if the appender is configured to log messages of
@@ -4,6 +4,6 @@ module Hatchet
4
4
 
5
5
  # Public: The version of Hatchet.
6
6
  #
7
- VERSION = '0.0.14'
7
+ VERSION = '0.0.15'
8
8
 
9
9
  end
data/lib/hatchet.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
+ require 'logger'
4
+
3
5
  require_relative 'hatchet/level_manager'
4
6
  require_relative 'hatchet/configuration'
5
7
  require_relative 'hatchet/delegating_formatter'
@@ -96,7 +96,7 @@ describe 'configuration' do
96
96
  before do
97
97
  assert appender.enabled?(:info, 'Foo')
98
98
  Hatchet.configure do |config|
99
- config.level = :fatal
99
+ config.level :fatal
100
100
  end
101
101
  end
102
102
 
@@ -64,7 +64,7 @@ describe LevelManager do
64
64
  describe 'altering the default level' do
65
65
  it 'alters the enabled level for subsequent calls' do
66
66
  assert @manager.enabled?(:info, 'Foo::Bar')
67
- @manager.level = :fatal
67
+ @manager.level :fatal
68
68
  refute @manager.enabled?(:info, 'Foo::Bar')
69
69
  end
70
70
  end
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.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: