Created
February 20, 2011 00:32
-
-
Save donavanm/835550 to your computer and use it in GitHub Desktop.
Adds json formatted ouput for Puppet applications
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
# Adds json formatted ouput for Puppet applications. | |
# Usage: puppet agent --logdest json | |
# Currently there's no way to load this as a plugin, see #6522. Appending this | |
# method to puppet/util/log/destinations.rb works. Meh. | |
# Would also be nice if Puppet::Util::Log had an #attributes method for | |
# accessors instead of instance_variable hacks. | |
Puppet::Util::Log.newdesttype :json do | |
def handle(msg) | |
message = {} | |
msg.instance_variables.each {|v| message[v.sub("@","")] = msg.instance_variable_get(v) } | |
puts message.to_pson | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a very usable json output mode in puppet now
--logdest=logstash_event
will do this without requiring patching (although it comes with a bit of boilerplate intended for logstash).