Hello community, here is the log from the commit of package rubygem-mixlib-log for openSUSE:Factory checked in at 2019-03-04 09:20:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-mixlib-log (Old) and /work/SRC/openSUSE:Factory/.rubygem-mixlib-log.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-mixlib-log" Mon Mar 4 09:20:16 2019 rev:10 rq:679524 version:3.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-mixlib-log/rubygem-mixlib-log.changes 2018-07-18 22:50:25.591659899 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-mixlib-log.new.28833/rubygem-mixlib-log.changes 2019-03-04 09:20:17.504601883 +0100 @@ -1,0 +2,12 @@ +Mon Jan 14 13:46:36 UTC 2019 - Stephan Kulow <co...@suse.com> + +- updated to version 3.0.1 + no changelog found + +------------------------------------------------------------------- +Wed Dec 19 07:10:41 UTC 2018 - Stephan Kulow <co...@suse.com> + +- updated to version 2.0.9 + no changelog found + +------------------------------------------------------------------- Old: ---- mixlib-log-2.0.4.gem New: ---- mixlib-log-3.0.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-mixlib-log.spec ++++++ --- /var/tmp/diff_new_pack.Sj33xb/_old 2019-03-04 09:20:19.632601500 +0100 +++ /var/tmp/diff_new_pack.Sj33xb/_new 2019-03-04 09:20:19.632601500 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-mixlib-log # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -24,15 +24,15 @@ # Name: rubygem-mixlib-log -Version: 2.0.4 +Version: 3.0.1 Release: 0 %define mod_name mixlib-log %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{ruby >= 2.2} +BuildRequires: %{ruby >= 2.3} BuildRequires: %{rubygem gem2rpm} BuildRequires: ruby-macros >= 5 -Url: https://www.chef.io +Url: https://github.com/chef/mixlib-log Source: https://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: A gem that provides a simple mixin for log functionality @@ -48,7 +48,7 @@ %install %gem_install \ - --doc-files="LICENSE README.md" \ + --doc-files="LICENSE" \ -f %gem_packages ++++++ mixlib-log-2.0.4.gem -> mixlib-log-3.0.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2018-04-12 09:45:13.000000000 +0200 +++ new/Gemfile 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -gemspec - -group :development do - gem "rdoc" - gem "bundler" -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NOTICE new/NOTICE --- old/NOTICE 2018-04-12 09:45:13.000000000 +0200 +++ new/NOTICE 1970-01-01 01:00:00.000000000 +0100 @@ -1,28 +0,0 @@ -============ -Mixin::Log Notices -============ - -Developed at Chef (http://www.chef.io). - - - * Copyright 2009-2016, Chef Software, Inc. <le...@chef.io> - -Mixin::Log incorporates code from Chef. The Chef notice file follows: - -============ -Chef Notices -============ - -Developed at Chef (http://www.chef.io). - -Contributors and Copyright holders: - - * Copyright 2008, Adam Jacob <a...@chef.io> - * Copyright 2008, Arjuna Christensen <a...@hjksolutions.com> - * Copyright 2008, Bryan McLellan <b...@loftninjas.org> - * Copyright 2008, Ezra Zygmuntowicz <e...@engineyard.com> - * Copyright 2009, Sean Cribbs <seancri...@gmail.com> - * Copyright 2009, Christopher Brown <c...@chef.io> - * Copyright 2009, Thom May <t...@clearairturbulence.org> - -Chef incorporates code modified from Open4 (http://www.codeforpeople.com/lib/ruby/open4/), which was written by Ara T. Howard. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2018-04-12 09:45:13.000000000 +0200 +++ new/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -# Mixlib::Log - -[![Build Status Master](https://travis-ci.org/chef/mixlib-log.svg?branch=master)](https://travis-ci.org/chef/mixlib-log) [![Gem Version](https://badge.fury.io/rb/mixlib-log.svg)](https://badge.fury.io/rb/mixlib-log) - -Mixlib::Log provides a mixin for enabling a class based logger object, a-la Merb, Chef, and Nanite. To use it: - -```ruby -require 'mixlib/log' - -class Log - extend Mixlib::Log -end -``` - -You can then do: - -```ruby -Log.debug('foo') -Log.info('bar') -Log.warn('baz') -Log.error('baz') -Log.fatal('wewt') -``` - -By default, `Mixlib::Logger` logs to STDOUT. To alter this, you should call `Log.init`, passing any arguments to the standard Ruby Logger. For example: - -```ruby -Log.init('/tmp/logfile') # log to /tmp/logfile -Log.init('/tmp/logfile', 7) # log to /tmp/logfile, rotate every day -``` - -Enjoy! - -## Contributing - -For information on contributing to this project see <https://github.com/chef/chef/blob/master/CONTRIBUTING.md> - -## License - -- Copyright:: Copyright (c) 2008-2016 Chef Software, Inc. -- License:: Apache License, Version 2.0 - -```text -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2018-04-12 09:45:13.000000000 +0200 +++ new/Rakefile 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -require "bundler/gem_tasks" -require "rdoc/task" -require "rspec/core/rake_task" -require "cucumber/rake/task" - -RSpec::Core::RakeTask.new(:spec) do |spec| - spec.pattern = "spec/**/*_spec.rb" -end - -task default: [:style, :spec, :features] - -# For rubygems-test -task :test => :spec - -RDoc::Task.new do |rdoc| - rdoc.rdoc_dir = "rdoc" - rdoc.title = "mixlib-log #{Mixlib::Log::VERSION}" - rdoc.rdoc_files.include("README*") - rdoc.rdoc_files.include("lib/**/*.rb") -end - -Cucumber::Rake::Task.new(:features) do |t| - t.cucumber_opts = "--format pretty" -end - -begin - require "chefstyle" - require "rubocop/rake_task" - RuboCop::RakeTask.new(:style) do |task| - task.options += ["--display-cop-names", "--no-color"] - end -rescue LoadError - puts "chefstyle/rubocop is not available. gem install chefstyle to do style checking." -end - -require "github_changelog_generator/task" - -GitHubChangelogGenerator::RakeTask.new :changelog do |config| - config.future_release = Mixlib::Log::VERSION - config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature".split(",") - config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",") - config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question,Discussion".split(",") -end Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/log/logging.rb new/lib/mixlib/log/logging.rb --- old/lib/mixlib/log/logging.rb 2018-04-12 09:45:13.000000000 +0200 +++ new/lib/mixlib/log/logging.rb 2019-01-05 00:30:09.000000000 +0100 @@ -29,7 +29,7 @@ SEV_LABEL[sev + 1] || -"ANY" end - LEVELS = { :trace => TRACE, :debug => DEBUG, :info => INFO, :warn => WARN, :error => ERROR, :fatal => FATAL }.freeze + LEVELS = { trace: TRACE, debug: DEBUG, info: INFO, warn: WARN, error: ERROR, fatal: FATAL }.freeze LEVEL_NAMES = LEVELS.invert.freeze attr_accessor :metadata diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/log/version.rb new/lib/mixlib/log/version.rb --- old/lib/mixlib/log/version.rb 2018-04-12 09:45:13.000000000 +0200 +++ new/lib/mixlib/log/version.rb 2019-01-05 00:30:09.000000000 +0100 @@ -1,5 +1,5 @@ module Mixlib module Log - VERSION = "2.0.4" + VERSION = "3.0.1".freeze end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2018-04-12 09:45:13.000000000 +0200 +++ new/metadata 2019-01-05 00:30:09.000000000 +0100 @@ -1,112 +1,29 @@ --- !ruby/object:Gem::Specification name: mixlib-log version: !ruby/object:Gem::Version - version: 2.0.4 + version: 3.0.1 platform: ruby authors: - Chef Software, Inc. autorequire: bindir: bin cert_chain: [] -date: 2018-04-12 00:00:00.000000000 Z -dependencies: -- !ruby/object:Gem::Dependency - name: rake - requirement: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' - type: :development - prerelease: false - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' -- !ruby/object:Gem::Dependency - name: rspec - requirement: !ruby/object:Gem::Requirement - requirements: - - - "~>" - - !ruby/object:Gem::Version - version: '3.7' - type: :development - prerelease: false - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - "~>" - - !ruby/object:Gem::Version - version: '3.7' -- !ruby/object:Gem::Dependency - name: chefstyle - requirement: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' - type: :development - prerelease: false - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' -- !ruby/object:Gem::Dependency - name: cucumber - requirement: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' - type: :development - prerelease: false - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' -- !ruby/object:Gem::Dependency - name: github_changelog_generator - requirement: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 1.11.3 - type: :development - prerelease: false - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 1.11.3 +date: 2019-01-04 00:00:00.000000000 Z +dependencies: [] description: email: i...@chef.io executables: [] extensions: [] -extra_rdoc_files: -- README.md -- LICENSE -- NOTICE +extra_rdoc_files: [] files: -- ".gemtest" -- Gemfile - LICENSE -- NOTICE -- README.md -- Rakefile - lib/mixlib/log.rb - lib/mixlib/log/child.rb - lib/mixlib/log/formatter.rb - lib/mixlib/log/logger.rb - lib/mixlib/log/logging.rb - lib/mixlib/log/version.rb -- mixlib-log.gemspec -- spec/mixlib/log/child_spec.rb -- spec/mixlib/log/formatter_spec.rb -- spec/mixlib/log_spec.rb -- spec/spec_helper.rb -homepage: https://www.chef.io +homepage: https://github.com/chef/mixlib-log licenses: - Apache-2.0 metadata: {} @@ -118,7 +35,7 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: '2.2' + version: '2.3' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mixlib-log.gemspec new/mixlib-log.gemspec --- old/mixlib-log.gemspec 2018-04-12 09:45:13.000000000 +0200 +++ new/mixlib-log.gemspec 1970-01-01 01:00:00.000000000 +0100 @@ -1,22 +0,0 @@ -$:.unshift File.expand_path("../lib", __FILE__) -require "mixlib/log/version" - -Gem::Specification.new do |gem| - gem.name = "mixlib-log" - gem.version = Mixlib::Log::VERSION - gem.platform = Gem::Platform::RUBY - gem.summary = "A gem that provides a simple mixin for log functionality" - gem.email = "i...@chef.io" - gem.homepage = "https://www.chef.io" - gem.license = "Apache-2.0" - gem.authors = ["Chef Software, Inc."] - gem.has_rdoc = true - gem.extra_rdoc_files = ["README.md", "LICENSE", "NOTICE"] - gem.files = Dir["lib/**/*"] + Dir["spec/**/*"] + ["Gemfile", "Rakefile", ".gemtest", "mixlib-log.gemspec"] - gem.required_ruby_version = ">= 2.2" - gem.add_development_dependency "rake" - gem.add_development_dependency "rspec", "~> 3.7" - gem.add_development_dependency "chefstyle" - gem.add_development_dependency "cucumber" - gem.add_development_dependency "github_changelog_generator", ">= 1.11.3" -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mixlib/log/child_spec.rb new/spec/mixlib/log/child_spec.rb --- old/spec/mixlib/log/child_spec.rb 2018-04-12 09:45:13.000000000 +0200 +++ new/spec/mixlib/log/child_spec.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,99 +0,0 @@ -# -# Copyright:: Copyright (c) 2018 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "tempfile" -require "stringio" -require "spec_helper" - -RSpec.describe Mixlib::Log::Child do - before do - Logit.reset! - Logit.init(io) - Logit.level = :warn - end - - let(:io) { StringIO.new } - - let(:child) { Logit.with_child } - - it "has a parent" do - expect(child.parent).to be(Logit) - end - - it "accepts a message" do - Logit.with_child { |l| l.add(Logger::WARN, "a message") } - expect(io.string).to match(/a message$/) - end - - context "with structured data" do - it "can be created with metadata" do - expect(Logit).to receive(:pass).with(Mixlib::Log::LEVELS[:warn], "a message", nil, data: { child: "true" }) - Logit.with_child({ child: "true" }) { |l| l.warn("a message") } - end - - it "a message can be logged" do - expect(Logit).to receive(:pass).with(Mixlib::Log::LEVELS[:warn], "a message", nil, data: { child: "true" }) - Logit.with_child { |l| l.warn("a message", data: { child: "true" }) } - end - - context "merges properly" do - it "in the simple case" do - expect(Logit).to receive(:pass).with(Mixlib::Log::LEVELS[:warn], "a message", nil, data: { child: "true", meta: "data" }) - Logit.with_child(meta: "data") { |l| l.warn("a message", data: { child: "true" }) } - end - - it "when overwriting" do - expect(Logit).to receive(:pass).with(Mixlib::Log::LEVELS[:warn], "a message", nil, data: { child: "true", meta: "overwritten" }) - Logit.with_child(meta: "data") { |l| l.warn("a message", data: { child: "true", meta: "overwritten" }) } - end - end - - context "when receiving a message from a child" do - it "passes data on" do - expect(Logit).to receive(:pass).with(Mixlib::Log::LEVELS[:warn], "a message", nil, data: { child: "true", parent: "first" }) - child.metadata = { parent: "first" } - child.with_child { |l| l.warn("a message", data: { child: "true" }) } - end - - it "merges its own data" do - expect(Logit).to receive(:pass).with(Mixlib::Log::LEVELS[:warn], "a message", nil, data: { child: "true", parent: "second" }) - child.metadata = { parent: "first" } - child.with_child { |l| l.warn("a message", data: { child: "true", parent: "second" }) } - end - end - end - - context "sends a message to the parent" do - %i{ debug info warn error fatal }.each do |level| - it "at #{level}" do - expect(Logit).to receive(:pass).with(Mixlib::Log::LEVELS[level], "a #{level} message", nil, data: {}) - Logit.level = level - child.send(level, "a #{level} message") - end - end - end - - context "can query the parent's level" do - %i{ debug info warn error fatal }.each do |level| - it "at #{level}" do - query = "#{level}?".to_sym - Logit.level = level - expect(child.send(query)).to be(true) - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mixlib/log/formatter_spec.rb new/spec/mixlib/log/formatter_spec.rb --- old/spec/mixlib/log/formatter_spec.rb 2018-04-12 09:45:13.000000000 +0200 +++ new/spec/mixlib/log/formatter_spec.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,64 +0,0 @@ -# -# Author:: Adam Jacob (<a...@chef.io>) -# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "time" -require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper")) - -RSpec.describe Mixlib::Log::Formatter do - before(:each) do - @formatter = Mixlib::Log::Formatter.new - end - - it "should print raw strings with msg2str(string)" do - expect(@formatter.msg2str("nuthin new")).to eq("nuthin new") - end - - it "should format exceptions properly with msg2str(e)" do - e = IOError.new("legendary roots crew") - expect(@formatter.msg2str(e)).to eq("legendary roots crew (IOError)\n") - end - - it "should format random objects via inspect with msg2str(Object)" do - expect(@formatter.msg2str([ "black thought", "?uestlove" ])).to eq('["black thought", "?uestlove"]') - end - - it "should return a formatted string with call" do - time = Time.new - Mixlib::Log::Formatter.show_time = true - expect(@formatter.call("monkey", time, "test", "mos def")).to eq("[#{time.iso8601}] monkey: mos def\n") - end - - it "should allow you to turn the time on and off in the output" do - Mixlib::Log::Formatter.show_time = false - expect(@formatter.call("monkey", Time.new, "test", "mos def")).to eq("monkey: mos def\n") - end - - context "with structured data" do - let(:data) { {} } - - it "should format a message" do - data[:msg] = "nuthin new" - expect(@formatter.msg2str(data)).to eq("nuthin new") - end - - it "should format an exception" do - data[:err] = IOError.new("legendary roots crew") - expect(@formatter.msg2str(data)).to eq("legendary roots crew (IOError)\n") - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mixlib/log_spec.rb new/spec/mixlib/log_spec.rb --- old/spec/mixlib/log_spec.rb 2018-04-12 09:45:13.000000000 +0200 +++ new/spec/mixlib/log_spec.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,234 +0,0 @@ -# -# Author:: Adam Jacob (<a...@chef.io>) -# Author:: Christopher Brown (<c...@chef.io>) -# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "tempfile" -require "stringio" -require "spec_helper" - -class LoggerLike - attr_accessor :level - attr_reader :messages, :data - def initialize - @messages = "" - @data = [] - end - - def add_data(severity, message = nil, progname = nil, data: {}) - @messages << message - @data << data - end - - def add(severity, message = nil, progname = nil, data: {}) - @messages << message - end - - [:trace, :debug, :info, :warn, :error, :fatal].each do |method_name| - class_eval(<<-E) - def #{method_name}(message) - @messages << message - end - E - end -end - -RSpec.describe Mixlib::Log do - - # Since we are testing class behaviour for an instance variable - # that gets set once, we need to reset it prior to each example [cb] - before(:each) do - Logit.reset! - end - - it "creates a logger using an IO object" do - io = StringIO.new - Logit.init(io) - Logit << "foo" - expect(io.string).to match(/foo/) - end - - it "creates a logger with a file name" do - Tempfile.open("chef-test-log") do |tempfile| - Logit.init(tempfile.path) - Logit << "bar" - tempfile.rewind - expect(tempfile.read).to match(/bar/) - end - end - - it "uses the logger provided when initialized with a logger like object" do - logger = LoggerLike.new - Logit.init(logger) - Logit.level = :debug - Logit.debug "qux" - expect(logger.messages).to match(/qux/) - end - - it "should re-initialize the logger if init is called again" do - first_logdev, second_logdev = StringIO.new, StringIO.new - Logit.init(first_logdev) - Logit.fatal "FIRST" - expect(first_logdev.string).to match(/FIRST/) - Logit.init(second_logdev) - Logit.fatal "SECOND" - expect(first_logdev.string).to_not match(/SECOND/) - expect(second_logdev.string).to match(/SECOND/) - end - - it "knows that it's been configured" do - Logit.init - expect(Logit.configured?).to be true - end - - it "should set the log level using the binding form, with :trace, :debug, :info, :warn, :error, or :fatal" do - levels = { - :trace => Mixlib::Log::TRACE, - :debug => Mixlib::Log::DEBUG, - :info => Mixlib::Log::INFO, - :warn => Mixlib::Log::WARN, - :error => Mixlib::Log::ERROR, - :fatal => Mixlib::Log::FATAL, - } - levels.each do |symbol, constant| - Logit.level = symbol - expect(Logit.logger.level).to eq(constant) - expect(Logit.level).to eq(symbol) - end - end - - it "passes blocks to the underlying logger object" do - logdev = StringIO.new - Logit.init(logdev) - Logit.fatal { "the_message" } - expect(logdev.string).to match(/the_message/) - end - - it "should set the log level using the method form, with :trace, :debug, :info, :warn, :error, or :fatal" do - levels = { - :trace => Mixlib::Log::TRACE, - :debug => Mixlib::Log::DEBUG, - :info => Mixlib::Log::INFO, - :warn => Mixlib::Log::WARN, - :error => Mixlib::Log::ERROR, - :fatal => Mixlib::Log::FATAL, - } - levels.each do |symbol, constant| - Logit.level(symbol) - expect(Logit.logger.level).to eq(constant) - end - end - - it "should raise an ArgumentError if you try and set the level to something strange using the binding form" do - expect(lambda { Logit.level = :the_roots }).to raise_error(ArgumentError) - end - - it "should raise an ArgumentError if you try and set the level to something strange using the method form" do - expect(lambda { Logit.level(:the_roots) }).to raise_error(ArgumentError) - end - - it "should pass other method calls directly to logger" do - Logit.level = :debug - expect(Logit).to be_debug - expect(lambda { Logit.debug("Gimme some sugar!") }).to_not raise_error - end - - it "should pass add method calls directly to logger" do - logdev = StringIO.new - Logit.init(logdev) - Logit.level = :debug - expect(Logit).to be_debug - expect(lambda { Logit.add(Logger::DEBUG, "Gimme some sugar!") }).to_not raise_error - expect(logdev.string).to match(/Gimme some sugar/) - end - - it "should default to STDOUT if init is called with no arguments" do - logger_mock = Struct.new(:formatter, :level).new - expect(Logger).to receive(:new).with(STDOUT).and_return(logger_mock) - Logit.init - end - - it "should have by default a base log level of warn" do - logger_mock = Struct.new(:formatter, :level).new - expect(Logger).to receive(:new).and_return(logger_mock) - Logit.init - expect(Logit.level).to eq(:warn) - end - - it "should close File logger" do - opened_files_count_before = 0 - ObjectSpace.each_object(File) do |f| - opened_files_count_before += 1 unless f.closed? - end - name = File.join(Dir.tmpdir, "logger.log") - Logit.init(name) - Logit.init(name) - Logit.init(name) - opened_files_count_after = 0 - ObjectSpace.each_object(File) do |f| - opened_files_count_after += 1 unless f.closed? - end - expect(opened_files_count_after).to eq(opened_files_count_before + 1) - end - - it "should not close IO logger" do - opened_files_count_before = 0 - ObjectSpace.each_object(File) do |f| - opened_files_count_before += 1 unless f.closed? - end - Tempfile.open("chef-test-log") do |file| - Logit.init(file) - Logit.init(file) - Logit.init(file) - opened_files_count_after = 0 - ObjectSpace.each_object(File) do |f| - opened_files_count_after += 1 unless f.closed? - end - expect(opened_files_count_after).to eq(opened_files_count_before + 1) - end - end - - it "should return nil from its logging methods" do - expect(Logger).to receive(:new).with(STDOUT) { double("a-quiet-logger").as_null_object } - Logit.init - - aggregate_failures "returns nil from logging method" do - expect(Logit.trace("hello")).to be_nil - expect(Logit.debug("hello")).to be_nil - expect(Logit.info("hello")).to be_nil - expect(Logit.warn("hello")).to be_nil - expect(Logit.error("hello")).to be_nil - expect(Logit.fatal("hello")).to be_nil - end - end - - it "should set metadata correctly" do - Logit.metadata = { test: "data" } - expect(Logit.metadata).to eql({ test: "data" }) - end - - it "should format :trace level messages with TRACE: label" do - logdev = StringIO.new - Logit.init(logdev) - Logit.level = :trace - Logit.trace("this is a log message") - aggregate_failures do - expect(logdev.string).to_not match(/ANY:/) - expect(logdev.string).to match(/TRACE:/) - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb --- old/spec/spec_helper.rb 2018-04-12 09:45:13.000000000 +0200 +++ new/spec/spec_helper.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,33 +0,0 @@ -# -# Author:: Adam Jacob (<a...@chef.io>) -# Author:: Christopher Brown (<c...@chef.io>) -# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -$TESTING = true -$:.push File.join(File.dirname(__FILE__), "..", "lib") - -require "rspec" -require "mixlib/log" -require "mixlib/log/formatter" - -RSpec.configure do |config| - config.disable_monkey_patching! -end - -class Logit - extend Mixlib::Log -end