in itchef/cookbooks/cpe_logger/libraries/cpe_log.rb [24:48]
def self.log(
msg,
level: :info,
type: 'chef',
action: nil,
actor: nil,
status: nil
)
fail_msg = 'status != success or fail'
fail fail_msg unless %w{success fail}.include?(status) || status.nil?
action = " action: #{action};" if action
actor = " actor: #{actor};" if actor
status = " status: #{status};" if status
msg = msg.to_s.tr("\n", ' ')
Chef::Log.send(level, "#{type};#{action}#{actor}#{status} #{msg}")
if Dir.exist?(File.dirname(log_path))
::File.write(
log_path,
"#{Time.now}; type: #{type};#{action}#{status} msg: #{msg};\n",
:mode => 'a',
)
end
end