This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #397 from ripienaar/394.2
(#394) improve logging and avoid overloading node
- Loading branch information
Showing
11 changed files
with
105 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require "mcollective/logger/console_logger" | ||
|
||
module MCollective | ||
module Util | ||
class Playbook | ||
class Puppet_Logger < Logger::Console_logger | ||
attr_writer :scope | ||
|
||
def initialize(playbook) | ||
@playbook = playbook | ||
@report = playbook.report | ||
|
||
super() | ||
end | ||
|
||
def start | ||
set_level(@playbook.loglevel.intern) | ||
end | ||
|
||
def log(level, from, msg, normal_output=STDERR, last_resort_output=STDERR) | ||
return unless should_show? | ||
|
||
logmethod = case level | ||
when :info | ||
:notice | ||
when :warn | ||
:warning | ||
when :error | ||
:err | ||
when :fatal | ||
:crit | ||
else | ||
:debug | ||
end | ||
|
||
if @scope | ||
Puppet::Util::Log.log_func(@scope, logmethod, [msg]) | ||
else | ||
Puppet.send(logmethod, msg) | ||
end | ||
end | ||
|
||
def should_show? | ||
!caller(1..5).grep(/playbook/).empty? | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters