Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adds json formatted ouput for Puppet applications
# 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

This comment has been minimized.

Copy link

anthonyryan1 commented Feb 13, 2015

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.