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 CHANGED
@@ -14,22 +14,31 @@ begin
14
14
  end
15
15
  Jeweler::GemcutterTasks.new
16
16
  rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install gemcutter jeweler (installs jeweler from gemcutter)"
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
- require 'spec/rake/spectask'
21
- Spec::Rake::SpecTask.new(:spec) do |spec|
22
- spec.libs << 'lib' << 'spec'
23
- spec.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
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
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
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'))
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 1
4
- :patch: 0
3
+ :minor: 2
4
+ :patch: 0
5
+ :build:
@@ -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
- if @logger.nil?
49
- @logger = (opts.empty? ? Logger.new(STDOUT) : Logger.new(*opts))
50
- @logger.formatter = Mixlib::Log::Formatter.new()
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
@@ -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
- tf = Tempfile.new("chef-test-log")
33
- tf.open
34
- lambda { Logit.init(STDOUT) }.should_not raise_error
35
- lambda { Logit.init(tf) }.should_not raise_error
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
- - 1
7
+ - 2
8
8
  - 0
9
- version: 1.1.0
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-02-28 00:00:00 -08:00
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.6
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