module LoggerJsonCore
Public Class Methods
included(klass)
click to toggle source
# File lib/core/logger_json_core.rb, line 2 def self.included(klass) %w{debug info warn error fatal}.each do |level| klass.send(:alias_method, "old_#{level}", level) block = Proc.new do |*args, &block| create_file args, level return send("old_#{level}", args[0]) { block.call } unless block.nil? send "old_#{level}", args[0] end klass.send(:define_method, level, block) end end
Private Instance Methods
create_file(message, type=:info)
click to toggle source
# File lib/core/logger_json_core.rb, line 18 def create_file(message, type=:info) path = filename || ENV['LOG_PATH'] || LoggerJson::Text::PATH json = LoggerJson::Model.new(message, type).json LoggerJson::Writter.logger_json(path, json) end
filename()
click to toggle source
# File lib/core/logger_json_core.rb, line 24 def filename return unless defined?(Syslog::Logger).nil? return if instance_variable_get('@logdev').nil? path = instance_variable_get('@logdev').filename return if path.nil? path.gsub('.log','-json.log') end