Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing logify #151

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/stove.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'logify'
require 'pathname'
require 'chef/log'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of stove is that it doesn't dep on chef. We need to use mixlib-log directly.


module Stove
autoload :Artifactory, 'stove/artifactory'
Expand Down Expand Up @@ -72,7 +72,7 @@ def root
# the log level to set
#
def log_level=(level)
Logify.level = level.to_sym
Chef::Log.level = level.to_sym
end

#
Expand All @@ -81,7 +81,7 @@ def log_level=(level)
# @return [Symbol]
#
def log_level
Logify.level
Chef::Log.level
end
end
end
14 changes: 6 additions & 8 deletions lib/stove/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

module Stove
class Cli
include Logify

def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
end
Expand Down Expand Up @@ -48,8 +46,8 @@ def execute!

# Useful debugging output for when people type the wrong fucking command
# and then open an issue like it's somehow my fault
log.info("Options: #{options.inspect}")
log.info("ARGV: #{@argv.inspect}")
Chef::Log.info("Options: #{options.inspect}")
Chef::Log.info("ARGV: #{@argv.inspect}")

# Make a new cookbook object - this will raise an exception if there is
# no cookbook at the given path
Expand All @@ -62,10 +60,10 @@ def execute!
# If we got this far, everything was successful :)
@kernel.exit(0)
rescue => e
log.error('Stove experienced an error!')
log.error(e.class.name)
log.error(e.message)
log.error(e.backtrace.join("\n"))
Chef::Log.error('Stove experienced an error!')
Chef::Log.error(e.class.name)
Chef::Log.error(e.message)
Chef::Log.error(e.backtrace.join("\n"))

@kernel.exit(e.respond_to?(:exit_code) ? e.exit_code : 500)
ensure
Expand Down
3 changes: 1 addition & 2 deletions lib/stove/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

module Stove
class Config
include Logify
include Mixin::Instanceable

def method_missing(m, *args, &block)
Expand Down Expand Up @@ -69,7 +68,7 @@ def __raw__

@__raw__
rescue Errno::ENOENT => e
log.warn { "No config file found at `#{__path__}'!" }
Chef::Log.warn { "No config file found at `#{__path__}'!" }
@__raw__ = {}
end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/stove/cookbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

module Stove
class Cookbook
include Logify

require_relative 'cookbook/metadata'

#
Expand Down
4 changes: 1 addition & 3 deletions lib/stove/filter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module Stove
class Filter
include Logify

include Mixin::Insideable

#
Expand Down Expand Up @@ -49,7 +47,7 @@ def initialize(klass, message, &block)
# the cookbook to run this filter against
#
def run(cookbook, options = {})
log.info(message)
Chef::Log.info(message)
instance = klass.new(cookbook, options)

inside(cookbook) do
Expand Down
2 changes: 0 additions & 2 deletions lib/stove/packager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

module Stove
class Packager
include Logify

ACCEPTABLE_FILES = [
'.foodcritic',
'README.*',
Expand Down
4 changes: 1 addition & 3 deletions lib/stove/plugins/base.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module Stove
class Plugin::Base
include Logify

extend Mixin::Optionable
extend Mixin::Validatable

class << self
def run(description, &block)
actions << Proc.new do |instance|
log.info { description }
Chef::Log.info description
instance.instance_eval(&block)
end
end
Expand Down
5 changes: 2 additions & 3 deletions lib/stove/runner.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Stove
class Runner
include Logify

attr_reader :cookbook
attr_reader :options
Expand All @@ -23,9 +22,9 @@ def run

def run_plugin(name)
if skip?(name)
log.info { "Skipping plugin `:#{name}'" }
Chef::Log.info "Skipping plugin `:#{name}'"
else
log.info { "Running plugin `:#{name}'" }
Chef::Log.info "Running plugin `:#{name}'"
klass = Plugin.const_get(Util.camelize(name))
klass.new(cookbook, options).run
end
Expand Down
8 changes: 3 additions & 5 deletions lib/stove/validator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module Stove
class Validator
include Logify

include Mixin::Insideable

#
Expand Down Expand Up @@ -49,20 +47,20 @@ def initialize(klass, id, &block)
# the cookbook to run this validation against
#
def run(cookbook, options = {})
log.info("Running validations for `#{klass.id}.#{id}'")
Chef::Log.info("Running validations for `#{klass.id}.#{id}'")

inside(cookbook) do
instance = klass.new(cookbook, options)
unless result = instance.instance_eval(&block)
log.debug("Validation failed, result: #{result.inspect}")
Chef::Log.debug("Validation failed, result: #{result.inspect}")

# Convert the class and id to their magical equivalents
error = Error.const_get("#{Util.camelize(klass.id)}#{Util.camelize(id)}ValidationFailed")
raise error.new(path: Dir.pwd, result: result)
end
end

log.debug("Validation #{id} passed!")
Chef::Log.debug("Validation #{id} passed!")
end
end
end
2 changes: 1 addition & 1 deletion stove.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|

# Runtime dependencies
spec.add_dependency 'chef-infra-api', '~> 0.5'
spec.add_dependency 'logify', '~> 0.2'
spec.add_dependency 'chef'

spec.add_development_dependency 'aruba', '~> 0.6.0'
spec.add_development_dependency 'bundler'
Expand Down