summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-08-07 09:49:52 -0700
committerGitHub <noreply@github.com>2019-08-07 09:49:52 -0700
commitc7756710233ef80e383ecabef25074f5b7968544 (patch)
treee184ac80d8abb766fb817c023a64f32bb029c4c5
parent51dcee25b0ae6e614e5ebbc42eca0e1e3041865b (diff)
parent76b305a788968538b5ce0c7223b8b0fe470f0c31 (diff)
downloadmixlib-log-c7756710233ef80e383ecabef25074f5b7968544.tar.gz
Merge pull request #56 from chef/bk_fixes
Add windows testing in Buildkite
-rw-r--r--.expeditor/config.yml3
-rw-r--r--.expeditor/verify.pipeline.yml28
-rwxr-xr-xGemfile10
-rw-r--r--README.md1
-rw-r--r--Rakefile39
-rw-r--r--appveyor.yml43
-rw-r--r--lib/mixlib/log.rb10
-rw-r--r--lib/mixlib/log/child.rb4
-rw-r--r--lib/mixlib/log/formatter.rb2
-rw-r--r--lib/mixlib/log/logger.rb6
-rw-r--r--lib/mixlib/log/logging.rb2
-rw-r--r--spec/mixlib/log_spec.rb2
-rw-r--r--spec/spec_helper.rb4
13 files changed, 74 insertions, 80 deletions
diff --git a/.expeditor/config.yml b/.expeditor/config.yml
index 330b6a5..5283bc0 100644
--- a/.expeditor/config.yml
+++ b/.expeditor/config.yml
@@ -1,5 +1,6 @@
# Documentation available at https://expeditor.chef.io/docs/getting-started/
---
+
# Slack channel in Chef Software slack to send notifications about build failures, etc
slack:
notify_channel: chef-found-notify
@@ -11,6 +12,8 @@ rubygems:
github:
# This deletes the GitHub PR branch after successfully merged into the release branch
delete_branch_on_merge: true
+ # The tag format to use (e.g. v1.0.0)
+ version_tag_format: "v{{version}}"
# allow bumping the minor release via label
minor_bump_labels:
- "Expeditor: Bump Version Minor"
diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml
index a3efc1c..81cc2b6 100644
--- a/.expeditor/verify.pipeline.yml
+++ b/.expeditor/verify.pipeline.yml
@@ -1,28 +1,44 @@
+---
+expeditor:
+ defaults:
+ buildkite:
+ timeout_in_minutes: 30
+
steps:
- label: run-lint-and-specs-ruby-2.4
command:
- - asdf local ruby 2.4.5
- - bundle install --jobs=7 --retry=3
+ - bundle install --jobs=7 --retry=3 --without docs debug
- bundle exec rake
expeditor:
executor:
docker:
+ image: ruby:2.4-stretch
- label: run-lint-and-specs-ruby-2.5
command:
- - asdf local ruby 2.5.5
- - bundle install --jobs=7 --retry=3
+ - bundle install --jobs=7 --retry=3 --without docs debug
- bundle exec rake
expeditor:
executor:
docker:
+ image: ruby:2.5-stretch
- label: run-lint-and-specs-ruby-2.6
command:
- - asdf local ruby 2.6.3
- - bundle install --jobs=7 --retry=3
+ - bundle install --jobs=7 --retry=3 --without docs debug
+ - bundle exec rake
+ expeditor:
+ executor:
+ docker:
+ image: ruby:2.6-stretch
+
+- label: run-specs-windows
+ command:
+ - bundle install --jobs=7 --retry=3 --without docs debug
+ - bundle env
- bundle exec rake
expeditor:
executor:
docker:
+ host_os: windows
diff --git a/Gemfile b/Gemfile
index 432ee84..60cad82 100755
--- a/Gemfile
+++ b/Gemfile
@@ -3,19 +3,19 @@ source "https://rubygems.org"
gemspec
group :docs do
- gem "yard"
- gem "redcarpet"
gem "github-markup"
+ gem "redcarpet"
+ gem "yard"
end
group :test do
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
- gem "rspec", "~> 3.7"
+ gem "chefstyle"
gem "cucumber"
gem "rake"
+ gem "rspec", "~> 3.7"
end
-group :development do
+group :debug do
gem "pry"
gem "pry-byebug"
gem "pry-stack_explorer"
diff --git a/README.md b/README.md
index 1641158..bf0a770 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# Mixlib::Log
[![Gem Version](https://badge.fury.io/rb/mixlib-log.svg)](https://badge.fury.io/rb/mixlib-log)
+[![Build status](https://badge.buildkite.com/cb1e5b6f3cc77071f4b2315f6b605fe60d86e2862a490873d4.svg?branch=master)](https://buildkite.com/chef-oss/chef-mixlib-log-master-verify)
**Umbrella Project**: [Chef Foundation](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-foundation.md)
diff --git a/Rakefile b/Rakefile
index 1b9ec9a..5442c99 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,28 +1,41 @@
-require "bundler/gem_tasks"
-require "rspec/core/rake_task"
-require "cucumber/rake/task"
+require "bundler"
-task default: [:style, :spec, :features]
-
-Bundler::GemHelper.install_tasks
+begin
+ require "cucumber/rake/task"
-desc "Run specs"
-RSpec::Core::RakeTask.new(:spec) do |spec|
- spec.pattern = "spec/**/*_spec.rb"
+ Cucumber::Rake::Task.new(:features) do |t|
+ t.cucumber_opts = "--format pretty"
+ t.bundler = false
+ end
+rescue LoadError
+ desc "cucumber is not installed, this task is disabled"
+ task :spec do
+ abort "cucumber is not installed. bundle install first to make sure all dependencies are installed."
+ end
end
-Cucumber::Rake::Task.new(:features) do |t|
- t.cucumber_opts = "--format pretty"
+begin
+ require "rspec/core/rake_task"
+
+ RSpec::Core::RakeTask.new do |t|
+ t.pattern = "spec/**/*_spec.rb"
+ end
+rescue LoadError
+ desc "rspec is not installed, this task is disabled"
+ task :spec do
+ abort "rspec is not installed. bundle install first to make sure all dependencies are installed."
+ end
end
begin
require "chefstyle"
require "rubocop/rake_task"
+ desc "Run Chefstyle tests"
RuboCop::RakeTask.new(:style) do |task|
task.options += ["--display-cop-names", "--no-color"]
end
rescue LoadError
- puts "chefstyle/rubocop is not available. bundle install first to make sure all dependencies are installed."
+ puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
end
begin
@@ -39,3 +52,5 @@ task :console do
ARGV.clear
IRB.start
end
+
+task default: %i{style spec features}
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 023ea09..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-version: "master-{build}"
-
-os: Visual Studio 2017
-platform:
- - x64
-
-cache:
- - vendor/bundle
-
-environment:
- matrix:
- - ruby_version: "24-x64"
- - ruby_version: "25-x64"
- - ruby_version: "26-x64"
-
-clone_depth: 1
-skip_tags: true
-skip_branch_with_pr: true
-branches:
- only:
- - master
-
-install:
- - systeminfo
- - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
- - echo %PATH%
- - appveyor DownloadFile http://curl.haxx.se/ca/cacert.pem -FileName C:\cacert.pem
- - set SSL_CERT_FILE=C:\cacert.pem
- - SET BUNDLE_WITHOUT=server:docgen:maintenance:pry:travis:integration:ci
- - bundle config --local path vendor/bundle # use the cache we define above
- - bundle install || bundle install || bundle install
-
-build: off
-
-before_test:
- - ruby --version
- - gem --version
- - bundler --version
- - bundle env
-
-test_script:
- - SET SPEC_OPTS=--format progress
- - bundle exec rake \ No newline at end of file
diff --git a/lib/mixlib/log.rb b/lib/mixlib/log.rb
index e57ffcd..d15663c 100644
--- a/lib/mixlib/log.rb
+++ b/lib/mixlib/log.rb
@@ -61,7 +61,7 @@ module Mixlib
if other.respond_to?(:loggers) && other.respond_to?(:logger)
@loggers = other.loggers
@logger = other.logger
- elsif other.kind_of?(Array)
+ elsif other.is_a?(Array)
@loggers = other
@logger = other.first
else
@@ -82,7 +82,7 @@ module Mixlib
def init(*opts)
reset!
@logger = logger_for(*opts)
- @logger.formatter = Mixlib::Log::Formatter.new() if @logger.respond_to?(:formatter=)
+ @logger.formatter = Mixlib::Log::Formatter.new if @logger.respond_to?(:formatter=)
@logger.level = Logger::WARN
@configured = true
@parent = nil
@@ -110,6 +110,7 @@ module Mixlib
def level=(new_level)
level_int = LEVEL_NAMES.key?(new_level) ? new_level : LEVELS[new_level]
raise ArgumentError, "Log level must be one of :trace, :debug, :info, :warn, :error, or :fatal" if level_int.nil?
+
loggers.each { |l| l.level = level_int }
end
@@ -125,7 +126,7 @@ module Mixlib
# Note that we *only* query the default logger (@logger) and not any other
# loggers that may have been added, even though it is possible to configure
# two (or more) loggers at different log levels.
- [:trace?, :debug?, :info?, :warn?, :error?, :fatal?].each do |method_name|
+ %i{trace? debug? info? warn? error? fatal?}.each do |method_name|
define_method(method_name) do
logger.send(method_name)
end
@@ -137,7 +138,7 @@ module Mixlib
def add(severity, message = nil, progname = nil, data: {}, &block)
message, progname, data = yield if block_given?
- data = metadata.merge(data) if metadata.kind_of?(Hash) && data.kind_of?(Hash)
+ data = metadata.merge(data) if metadata.is_a?(Hash) && data.is_a?(Hash)
loggers.each do |l|
# if we don't have any metadata, let's not do the potentially expensive
# merging and managing that this call requires
@@ -193,6 +194,7 @@ module Mixlib
# to get access to it.
next unless logger.instance_variable_defined?(:"@logdev")
next unless (logdev = logger.instance_variable_get(:"@logdev"))
+
loggers_to_close << logger if logdev.filename
end
loggers_to_close
diff --git a/lib/mixlib/log/child.rb b/lib/mixlib/log/child.rb
index 56376c5..2d7de00 100644
--- a/lib/mixlib/log/child.rb
+++ b/lib/mixlib/log/child.rb
@@ -36,14 +36,14 @@ module Mixlib
# Note that we *only* query the default logger (@logger) and not any other
# loggers that may have been added, even though it is possible to configure
# two (or more) loggers at different log levels.
- [:trace?, :debug?, :info?, :warn?, :error?, :fatal?].each do |method_name|
+ %i{trace? debug? info? warn? error? fatal?}.each do |method_name|
define_method(method_name) do
parent.send(method_name)
end
end
def add(severity, message = nil, progname = nil, data: {}, &block)
- data = metadata.merge(data) if data.kind_of?(Hash)
+ data = metadata.merge(data) if data.is_a?(Hash)
parent.send(:pass, severity, message, progname, data: data, &block)
end
diff --git a/lib/mixlib/log/formatter.rb b/lib/mixlib/log/formatter.rb
index 1727452..680836f 100644
--- a/lib/mixlib/log/formatter.rb
+++ b/lib/mixlib/log/formatter.rb
@@ -31,7 +31,7 @@ module Mixlib
# Otherwise, doesn't print the time.
def call(severity, time, progname, msg)
if @@show_time
- sprintf("[%s] %s: %s\n", time.iso8601(), severity, msg2str(msg))
+ sprintf("[%s] %s: %s\n", time.iso8601, severity, msg2str(msg))
else
sprintf("%s: %s\n", severity, msg2str(msg))
end
diff --git a/lib/mixlib/log/logger.rb b/lib/mixlib/log/logger.rb
index f227f23..e1f8929 100644
--- a/lib/mixlib/log/logger.rb
+++ b/lib/mixlib/log/logger.rb
@@ -45,14 +45,16 @@ module Mixlib
def add_data(severity, message, progname, data: {})
return true if @logdev.nil? || severity < @level
+
data ||= {}
- if message.kind_of?(::Exception)
+ if message.is_a?(::Exception)
data[:err] = message
else
data[:msg] = message
end
@logdev.write(
- format_message(to_label(severity), Time.now, progname, data))
+ format_message(to_label(severity), Time.now, progname, data)
+ )
true
end
alias_method :add, :add_data
diff --git a/lib/mixlib/log/logging.rb b/lib/mixlib/log/logging.rb
index 524900b..5a7a076 100644
--- a/lib/mixlib/log/logging.rb
+++ b/lib/mixlib/log/logging.rb
@@ -41,7 +41,7 @@ module Mixlib
# Define the standard logger methods on this class programmatically.
# No need to incur method_missing overhead on every log call.
- [:trace, :debug, :info, :warn, :error, :fatal].each do |method_name|
+ %i{trace debug info warn error fatal}.each do |method_name|
level = LEVELS[method_name]
define_method(method_name) do |msg = nil, data: {}, &block|
pass(level, msg, data: data, &block)
diff --git a/spec/mixlib/log_spec.rb b/spec/mixlib/log_spec.rb
index b58c4e2..5366dcd 100644
--- a/spec/mixlib/log_spec.rb
+++ b/spec/mixlib/log_spec.rb
@@ -38,7 +38,7 @@ class LoggerLike
@messages << message
end
- [:trace, :debug, :info, :warn, :error, :fatal].each do |method_name|
+ %i{trace debug info warn error fatal}.each do |method_name|
class_eval(<<-E)
def #{method_name}(message)
@messages << message
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index a2de3b9..e8a1bb1 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -24,9 +24,7 @@ require "rspec"
require "mixlib/log"
require "mixlib/log/formatter"
-RSpec.configure do |config|
- config.disable_monkey_patching!
-end
+RSpec.configure(&:disable_monkey_patching!)
class Logit
extend Mixlib::Log