summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chef-zero.gemspec1
-rw-r--r--lib/chef_zero.rb2
-rw-r--r--lib/chef_zero/log.rb7
-rw-r--r--lib/chef_zero/rest_router.rb4
-rw-r--r--lib/chef_zero/server.rb4
5 files changed, 14 insertions, 4 deletions
diff --git a/chef-zero.gemspec b/chef-zero.gemspec
index ab57a8f..224ea6d 100644
--- a/chef-zero.gemspec
+++ b/chef-zero.gemspec
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
s.add_dependency 'chef' # For version, version constraint and deep merge
s.add_dependency 'thin' # webrick DOES NOT FREAKING WORK
+ s.add_dependency 'mixlib-log', '>= 1.3.0'
s.bindir = "bin"
s.executables = %w( chef-zero )
diff --git a/lib/chef_zero.rb b/lib/chef_zero.rb
index 2e91115..879c4cb 100644
--- a/lib/chef_zero.rb
+++ b/lib/chef_zero.rb
@@ -1,4 +1,6 @@
module ChefZero
+ autoload :Log, 'chef_zero/log'
+
CERTIFICATE = "-----BEGIN CERTIFICATE-----\nMIIDMzCCApygAwIBAgIBATANBgkqhkiG9w0BAQUFADCBnjELMAkGA1UEBhMCVVMx\nEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxFjAUBgNVBAoM\nDU9wc2NvZGUsIEluYy4xHDAaBgNVBAsME0NlcnRpZmljYXRlIFNlcnZpY2UxMjAw\nBgNVBAMMKW9wc2NvZGUuY29tL2VtYWlsQWRkcmVzcz1hdXRoQG9wc2NvZGUuY29t\nMB4XDTEyMTEyMTAwMzQyMVoXDTIyMTExOTAwMzQyMVowgZsxEDAOBgNVBAcTB1Nl\nYXR0bGUxEzARBgNVBAgTCldhc2hpbmd0b24xCzAJBgNVBAYTAlVTMRwwGgYDVQQL\nExNDZXJ0aWZpY2F0ZSBTZXJ2aWNlMRYwFAYDVQQKEw1PcHNjb2RlLCBJbmMuMS8w\nLQYDVQQDFCZVUkk6aHR0cDovL29wc2NvZGUuY29tL0dVS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omEUD8ls1UuoTIXRNGZ0VsZXu7OErXCK0JKNNyqRmOwcvYL\nJRqLfnlei5Ndo1lu286yL74c5rdTLs/nI2p4e+0CgYB079ZmcLeILrmfBoFI8+Y/\ngJLmPrFvXBOE6+lRV7kqUFPtZ6I3yQzyccETZTDvrnx0WjaiFavUPH27WMjY01S2\nTMtO0Iq1MPsbSrglO1as8MvjB9ldFcvp7gy4Q0Sv6XT0yqJ/S+vo8Df0m+H4UBpU\nf5o6EwBSd/UQxwtZIE0lsQKBgQCswfjX8Eg8KL/lJNpIOOE3j4XXE9ptksmJl2sB\njxDnQYoiMqVO808saHVquC/vTrpd6tKtNpehWwjeTFuqITWLi8jmmQ+gNTKsC9Gn\n1Pxf2Gb67PqnEpwQGln+TRtgQ5HBrdHiQIi+5am+gnw89pDrjjO5rZwhanAo6KPJ\n1zcPNQKBgQDxFu8v4frDmRNCVaZS4f1B6wTrcMrnibIDlnzrK9GG6Hz1U7dDv8s8\nNf4UmeMzDXjlPWZVOvS5+9HKJPdPj7/onv8B2m18+lcgTTDJBkza7R1mjL1Cje/Z\nKcVGsryKN6cjE7yCDasnA7R2rVBV/7NWeJV77bmzT5O//rW4yIfUIg==\n-----END RSA PRIVATE KEY-----\n"
diff --git a/lib/chef_zero/log.rb b/lib/chef_zero/log.rb
new file mode 100644
index 0000000..5ab1c6a
--- /dev/null
+++ b/lib/chef_zero/log.rb
@@ -0,0 +1,7 @@
+require 'mixlib/log'
+
+module ChefZero
+ class Log
+ extend Mixlib::Log
+ end
+end
diff --git a/lib/chef_zero/rest_router.rb b/lib/chef_zero/rest_router.rb
index 66ccace..a8ba173 100644
--- a/lib/chef_zero/rest_router.rb
+++ b/lib/chef_zero/rest_router.rb
@@ -14,7 +14,7 @@ module ChefZero
def call(request)
begin
- Chef::Log.debug "Request: #{request}"
+ ChefZero::Log.debug "Request: #{request}"
clean_path = "/" + request.rest_path.join("/")
routes.each do |route, endpoint|
if route.match(clean_path)
@@ -23,7 +23,7 @@ module ChefZero
end
not_found.call(request)
rescue
- Chef::Log.error("#{$!.inspect}\n#{$!.backtrace.join("\n")}")
+ ChefZero::Log.error("#{$!.inspect}\n#{$!.backtrace.join("\n")}")
[500, {"Content-Type" => "text/plain"}, "Exception raised! #{$!.inspect}\n#{$!.backtrace.join("\n")}"]
end
end
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb
index 8d7181b..2002b61 100644
--- a/lib/chef_zero/server.rb
+++ b/lib/chef_zero/server.rb
@@ -87,7 +87,7 @@ module ChefZero
server.start
rescue
@server_error = $!
- Chef::Log.error("#{$!.message}\n#{$!.backtrace.join("\n")}")
+ ChefZero::Log.error("#{$!.message}\n#{$!.backtrace.join("\n")}")
end
end
Timeout::timeout(timeout) do
@@ -107,7 +107,7 @@ module ChefZero
@thread.join(timeout)
@thread = nil
rescue
- Chef::Log.error("Server did not stop within #{timeout}s. Killing.")
+ ChefZero::Log.error("Server did not stop within #{timeout}s. Killing.")
@thread.kill if @thread
@thread = nil
end