lumber 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README.md +2 -1
- data/lib/lumber/level_util.rb +2 -2
- data/lib/lumber/server.rb +1 -1
- data/lib/lumber/version.rb +1 -1
- data/lumber.gemspec +1 -0
- data/spec/level_util_spec.rb +11 -7
- data/spec/server_spec.rb +13 -1
- metadata +18 -2
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -54,9 +54,10 @@ If you want to change the log level for a different environment, you can do so i
|
|
54
54
|
|
55
55
|
Lumber also comes with a Sinatra UI for dynamically overriding log levels at runtime. To use it, just run Lumber::Server as a rack application. The easiest way to do this is to map it to a route in your rails routes.rb (make sure you password protect it):
|
56
56
|
|
57
|
+
require 'lumber/server'
|
57
58
|
mount Lumber::Server, :at => "/lumber"
|
58
59
|
|
59
|
-
This will allow you to temporarily set lower log levels for specific loggers - e.g. if you want a specific model to have DEBUG logging for the next hour.
|
60
|
+
This will allow you to temporarily set lower log levels for specific loggers - e.g. if you want a specific model to have DEBUG logging for the next hour.
|
60
61
|
|
61
62
|
|
62
63
|
Copyright
|
data/lib/lumber/level_util.rb
CHANGED
@@ -33,8 +33,7 @@ module Lumber
|
|
33
33
|
# @param [Hash] Logger fullname mapping to level name, e.g. {'rails::models::User' => 'DEBUG'}
|
34
34
|
#
|
35
35
|
def set_levels(levels)
|
36
|
-
|
37
|
-
@cache_provider.write(LOG_LEVELS_KEY, levels, :expire_in => @ttl)
|
36
|
+
@cache_provider.write(LOG_LEVELS_KEY, levels, :expires_in => @ttl)
|
38
37
|
end
|
39
38
|
|
40
39
|
def get_levels()
|
@@ -50,6 +49,7 @@ module Lumber
|
|
50
49
|
if levels.size == 0
|
51
50
|
restore_levels
|
52
51
|
else
|
52
|
+
backup_levels(levels.keys)
|
53
53
|
levels.each do |name, level|
|
54
54
|
logger = Lumber.find_or_create_logger(name)
|
55
55
|
level_val = Log4r::LNAMES.index(level)
|
data/lib/lumber/server.rb
CHANGED
data/lib/lumber/version.rb
CHANGED
data/lumber.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.add_development_dependency("rake")
|
23
23
|
gem.add_development_dependency("rspec")
|
24
|
+
gem.add_development_dependency("rack-test")
|
24
25
|
gem.add_development_dependency("capybara")
|
25
26
|
gem.add_development_dependency("capybara-webkit")
|
26
27
|
gem.add_development_dependency("awesome_print")
|
data/spec/level_util_spec.rb
CHANGED
@@ -32,18 +32,21 @@ describe Lumber::LevelUtil do
|
|
32
32
|
it "creates logger if not yet defined" do
|
33
33
|
Log4r::Logger["unknownlogger"].should be_nil
|
34
34
|
LevelUtil.set_levels({"unknownlogger" => "DEBUG"})
|
35
|
+
LevelUtil.activate_levels
|
35
36
|
Log4r::Logger["unknownlogger"].should_not be_nil
|
36
37
|
end
|
37
38
|
|
38
39
|
it "reuses logger if already defined" do
|
39
|
-
|
40
|
-
foo_logger = Log4r::Logger[@name]
|
40
|
+
foo_logger = Lumber.find_or_create_logger(@name)
|
41
41
|
foo_logger.should_not be_nil
|
42
|
+
|
42
43
|
LevelUtil.set_levels({@name => "INFO"})
|
44
|
+
LevelUtil.activate_levels
|
43
45
|
Log4r::Logger[@name].should == foo_logger
|
44
46
|
end
|
45
47
|
|
46
48
|
it "activate level on logger" do
|
49
|
+
Lumber.find_or_create_logger(@name)
|
47
50
|
LevelUtil.set_levels({@name => "ERROR"})
|
48
51
|
Log4r::Logger[@name].level.should == Log4r::LNAMES.index("DEBUG")
|
49
52
|
LevelUtil.activate_levels
|
@@ -51,15 +54,16 @@ describe Lumber::LevelUtil do
|
|
51
54
|
end
|
52
55
|
|
53
56
|
it "restores levels when mapping expires" do
|
54
|
-
|
55
|
-
Log4r::Logger[
|
56
|
-
|
57
|
+
Lumber.find_or_create_logger(@name)
|
58
|
+
Log4r::Logger[@name].level.should == Log4r::LNAMES.index("DEBUG")
|
59
|
+
|
60
|
+
LevelUtil.set_levels({@name => "ERROR"})
|
57
61
|
LevelUtil.activate_levels
|
58
|
-
Log4r::Logger[
|
62
|
+
Log4r::Logger[@name].level.should == Log4r::LNAMES.index("ERROR")
|
59
63
|
|
60
64
|
LevelUtil.set_levels({})
|
61
65
|
LevelUtil.activate_levels
|
62
|
-
Log4r::Logger[
|
66
|
+
Log4r::Logger[@name].level.should == Log4r::LNAMES.index("DEBUG")
|
63
67
|
end
|
64
68
|
|
65
69
|
it "starts a monitor thread" do
|
data/spec/server_spec.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Lumber::Server, :type => :request do
|
4
|
-
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
5
6
|
before(:each) do
|
6
7
|
Capybara.app = Lumber::Server.new
|
7
8
|
end
|
8
9
|
|
10
|
+
def app
|
11
|
+
@app ||= Lumber::Server.new
|
12
|
+
end
|
13
|
+
|
9
14
|
it "should respond to it's url" do
|
10
15
|
visit "/levels"
|
11
16
|
page.should have_content('Logger Levels')
|
@@ -47,6 +52,13 @@ describe Lumber::Server, :type => :request do
|
|
47
52
|
|
48
53
|
page.should have_selector('form')
|
49
54
|
end
|
55
|
+
|
56
|
+
it "uses ttl set in current request" do
|
57
|
+
Lumber.find_or_create_logger("foo")
|
58
|
+
LevelUtil.cache_provider.should_receive(:write).with(LevelUtil::LOG_LEVELS_KEY, {"foo" => "INFO"}, :expires_in => 55)
|
59
|
+
|
60
|
+
post "/levels", {'ttl' => 55, 'levels' => [{'name' => "foo", "level" => "INFO"}]}
|
61
|
+
end
|
50
62
|
|
51
63
|
it "assigns level overrides", :js => true do
|
52
64
|
LevelUtil.set_levels({})
|
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.11.
|
4
|
+
version: 0.11.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log4r
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rack-test
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: capybara
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|