mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
parent
e470807399
commit
9561ade035
7 changed files with 41 additions and 36 deletions
|
@ -158,3 +158,5 @@ module LogStash
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "logstash/patches"
|
||||
|
|
3
lib/logstash/patches.rb
Normal file
3
lib/logstash/patches.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
require "logstash/patches/bugfix_jruby_2558"
|
||||
require "logstash/patches/cabin"
|
||||
require "logstash/patches/profile_require_calls"
|
34
lib/logstash/patches/cabin.rb
Normal file
34
lib/logstash/patches/cabin.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
if ENV["PROFILE_BAD_LOG_CALLS"] || $DEBUGLIST.include?("log")
|
||||
# Set PROFILE_BAD_LOG_CALLS=1 in your environment if you want
|
||||
# to track down logger calls that cause performance problems
|
||||
#
|
||||
# Related research here:
|
||||
# https://github.com/jordansissel/experiments/tree/master/ruby/logger-string-vs-block
|
||||
#
|
||||
# Basically, the following is wastes tons of effort creating objects that are
|
||||
# never used if the log level hides the log:
|
||||
#
|
||||
# logger.debug("something happend", :what => Happened)
|
||||
#
|
||||
# This is shown to be 4x faster:
|
||||
#
|
||||
# logger.debug(...) if logger.debug?
|
||||
#
|
||||
# I originally intended to use RubyParser and SexpProcessor to
|
||||
# process all the logstash ruby code offline, but it was much
|
||||
# faster to write this monkeypatch to warn as things are called.
|
||||
require "cabin/mixins/logger"
|
||||
module Cabin::Mixins::Logger
|
||||
LEVELS.keys.each do |level|
|
||||
m = "original_#{level}".to_sym
|
||||
predicate = "#{level}?".to_sym
|
||||
alias_method m, level
|
||||
define_method(level) do |*args|
|
||||
if !send(predicate)
|
||||
warn("Unconditional log call", :location => caller[0])
|
||||
end
|
||||
send(m, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end # PROFILE_BAD_LOG_CALLS
|
|
@ -1,3 +1,5 @@
|
|||
$DEBUGLIST = (ENV["DEBUG"] || "").split(",")
|
||||
|
||||
require "logstash/environment"
|
||||
|
||||
ENV["GEM_HOME"] = ENV["GEM_PATH"] = LogStash::Environment.logstash_gem_home
|
||||
|
|
|
@ -9,43 +9,7 @@ LogStash::Environment.bundler_setup!
|
|||
LogStash::Environment.load_locale!
|
||||
|
||||
Thread.abort_on_exception = true
|
||||
if ENV["PROFILE_BAD_LOG_CALLS"] || $DEBUGLIST.include?("log")
|
||||
# Set PROFILE_BAD_LOG_CALLS=1 in your environment if you want
|
||||
# to track down logger calls that cause performance problems
|
||||
#
|
||||
# Related research here:
|
||||
# https://github.com/jordansissel/experiments/tree/master/ruby/logger-string-vs-block
|
||||
#
|
||||
# Basically, the following is wastes tons of effort creating objects that are
|
||||
# never used if the log level hides the log:
|
||||
#
|
||||
# logger.debug("something happend", :what => Happened)
|
||||
#
|
||||
# This is shown to be 4x faster:
|
||||
#
|
||||
# logger.debug(...) if logger.debug?
|
||||
#
|
||||
# I originally intended to use RubyParser and SexpProcessor to
|
||||
# process all the logstash ruby code offline, but it was much
|
||||
# faster to write this monkeypatch to warn as things are called.
|
||||
require "cabin/mixins/logger"
|
||||
module Cabin::Mixins::Logger
|
||||
LEVELS.keys.each do |level|
|
||||
m = "original_#{level}".to_sym
|
||||
predicate = "#{level}?".to_sym
|
||||
alias_method m, level
|
||||
define_method(level) do |*args|
|
||||
if !send(predicate)
|
||||
warn("Unconditional log call", :location => caller[0])
|
||||
end
|
||||
send(m, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end # PROFILE_BAD_LOG_CALLS
|
||||
|
||||
require "logstash/monkeypatches-for-bugs"
|
||||
require "logstash/monkeypatches-for-debugging"
|
||||
require "logstash/namespace"
|
||||
require "logstash/program"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue