mixlib-log 1.1.0 → 1.2.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.
- data/Rakefile +22 -11
- data/VERSION.yml +3 -2
- data/lib/mixlib/log.rb +6 -8
- data/spec/mixlib/log_spec.rb +24 -5
- metadata +6 -4
data/Rakefile
CHANGED
@@ -14,22 +14,31 @@ begin
|
|
14
14
|
end
|
15
15
|
Jeweler::GemcutterTasks.new
|
16
16
|
rescue LoadError
|
17
|
-
puts
|
17
|
+
STDERR.puts
|
18
|
+
STDERR.puts "Jeweler is not installed. (sudo) gem install jeweler to use gem packaging tasks"
|
19
|
+
STDERR.puts
|
18
20
|
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
spec
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
begin
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
+
end
|
26
29
|
|
27
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
spec.rcov = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :spec do
|
37
|
+
abort "Rspec is not available. (sudo) gem install rspec to run unit tests"
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
41
|
+
|
33
42
|
begin
|
34
43
|
require 'cucumber/rake/task'
|
35
44
|
Cucumber::Rake::Task.new(:features)
|
@@ -42,6 +51,8 @@ end
|
|
42
51
|
task :default => :spec
|
43
52
|
|
44
53
|
require 'rake/rdoctask'
|
54
|
+
require 'yaml'
|
55
|
+
|
45
56
|
Rake::RDocTask.new do |rdoc|
|
46
57
|
if File.exist?('VERSION.yml')
|
47
58
|
config = YAML.load(File.read('VERSION.yml'))
|
data/VERSION.yml
CHANGED
data/lib/mixlib/log.rb
CHANGED
@@ -30,7 +30,7 @@ module Mixlib
|
|
30
30
|
# and creates a new one if it doesn't yet exist
|
31
31
|
##
|
32
32
|
def logger
|
33
|
-
init
|
33
|
+
@logger || init
|
34
34
|
end
|
35
35
|
|
36
36
|
def logger=(value)
|
@@ -45,11 +45,9 @@ module Mixlib
|
|
45
45
|
#
|
46
46
|
# It also configures the Logger instance it creates to use the custom Mixlib::Log::Formatter class.
|
47
47
|
def init(*opts)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
@logger.level = Logger::WARN
|
52
|
-
end
|
48
|
+
@logger = (opts.empty? ? Logger.new(STDOUT) : Logger.new(*opts))
|
49
|
+
@logger.formatter = Mixlib::Log::Formatter.new()
|
50
|
+
@logger.level = Logger::WARN
|
53
51
|
@logger
|
54
52
|
end
|
55
53
|
|
@@ -79,8 +77,8 @@ module Mixlib
|
|
79
77
|
# Passes any other method calls on directly to the underlying Logger object created with init. If
|
80
78
|
# this method gets hit before a call to Mixlib::Logger.init has been made, it will call
|
81
79
|
# Mixlib::Logger.init() with no arguments.
|
82
|
-
def method_missing(method_symbol, *args)
|
83
|
-
logger.send(method_symbol, *args)
|
80
|
+
def method_missing(method_symbol, *args, &block)
|
81
|
+
logger.send(method_symbol, *args, &block)
|
84
82
|
end
|
85
83
|
|
86
84
|
end
|
data/spec/mixlib/log_spec.rb
CHANGED
@@ -29,10 +29,21 @@ describe Mixlib::Log do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should accept regular options to Logger.new via init" do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
Tempfile.open("chef-test-log") do |tf|
|
33
|
+
lambda { Logit.init(STDOUT) }.should_not raise_error
|
34
|
+
lambda { Logit.init(tf) }.should_not raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should re-initialize the logger if init is called again" do
|
39
|
+
first_logdev, second_logdev = StringIO.new, StringIO.new
|
40
|
+
Logit.init(first_logdev)
|
41
|
+
Logit.fatal "FIRST"
|
42
|
+
first_logdev.string.should match(/FIRST/)
|
43
|
+
Logit.init(second_logdev)
|
44
|
+
Logit.fatal "SECOND"
|
45
|
+
first_logdev.string.should_not match(/SECOND/)
|
46
|
+
second_logdev.string.should match(/SECOND/)
|
36
47
|
end
|
37
48
|
|
38
49
|
it "should set the log level using the binding form, with :debug, :info, :warn, :error, or :fatal" do
|
@@ -49,7 +60,15 @@ describe Mixlib::Log do
|
|
49
60
|
Logit.level.should == symbol
|
50
61
|
end
|
51
62
|
end
|
52
|
-
|
63
|
+
|
64
|
+
it "passes blocks to the underlying logger object" do
|
65
|
+
logdev = StringIO.new
|
66
|
+
Logit.init(logdev)
|
67
|
+
Logit.fatal { "the_message" }
|
68
|
+
logdev.string.should match(/the_message/)
|
69
|
+
end
|
70
|
+
|
71
|
+
|
53
72
|
it "should set the log level using the method form, with :debug, :info, :warn, :error, or :fatal" do
|
54
73
|
levels = {
|
55
74
|
:debug => Logger::DEBUG,
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 1.
|
9
|
+
version: 1.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Opscode, Inc.
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-19 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -54,6 +54,7 @@ rdoc_options:
|
|
54
54
|
require_paths:
|
55
55
|
- lib
|
56
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
57
58
|
requirements:
|
58
59
|
- - ">="
|
59
60
|
- !ruby/object:Gem::Version
|
@@ -61,6 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
62
|
- 0
|
62
63
|
version: "0"
|
63
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
64
66
|
requirements:
|
65
67
|
- - ">="
|
66
68
|
- !ruby/object:Gem::Version
|
@@ -70,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
72
|
requirements: []
|
71
73
|
|
72
74
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.3.
|
75
|
+
rubygems_version: 1.3.7
|
74
76
|
signing_key:
|
75
77
|
specification_version: 3
|
76
78
|
summary: A gem that provides a simple mixin for log functionality
|