X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fdebugger.rb;h=2895cd0beadf678c3ec01ba3aec2c35e9d22d9c7;hb=052217de30c59206d7025b582d4604557a747470;hp=fe000324e8383118dd898d54588e05f3172321ba;hpb=5dc41054c67436ce2d2a14729472d6cb08b9cc37;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/debugger.rb b/data/rbot/plugins/debugger.rb index fe000324..2895cd0b 100644 --- a/data/rbot/plugins/debugger.rb +++ b/data/rbot/plugins/debugger.rb @@ -8,22 +8,26 @@ # License:: GPL v2 class DebugPlugin < Plugin - BotConfig.register BotConfigIntegerValue.new('debug.interval', + Config.register Config::IntegerValue.new('debug.interval', :default => 10, :validate => Proc.new{|v| v > 0}, :desc => "Number of seconds between memory profile dumps") - BotConfig.register BotConfigBooleanValue.new('debug.dump_strings', + Config.register Config::BooleanValue.new('debug.dump_strings', :default => false, :desc => "Set to true if you want the profiler to dump strings, false otherwise") - BotConfig.register BotConfigStringValue.new('debug.logdir', + Config.register Config::StringValue.new('debug.logdir', :default => "", :desc => "Directory where profile/string dumps are to be stored") + def dirname + @bot.config['debug.logdir'] + end + def initialize super @prev = Hash.new(0) @curr = Hash.new(0) @delta = Hash.new(0) - @file = File.open("#{@bot.botclass}/#{@bot.config['debug.logdir']}/memory_profiler.log",'w') + @file = File.open(datafile("memory_profiler.log"), 'w') @thread = @bot.timer.add(@bot.config['debug.interval']) { begin GC.start @@ -39,7 +43,7 @@ class DebugPlugin < Plugin end if @bot.config['debug.dump_strings'] - File.open("#{@bot.botclass}/#{@bot.config['debug.logdir']}/memory_profiler_strings.log.#{Time.now.to_i}",'w') do |f| + File.open(datafile("memory_profiler_strings.log.#{Time.now.to_i}"), 'w') do |f| curr_strings.sort.each do |s| f.puts s end @@ -107,7 +111,7 @@ class DebugPlugin < Plugin end end - File.open("#{@bot.botclass}/#{@bot.config['debug.logdir']}/memory_profiler_strings.log.#{Time.now.to_i}",'w') do |f| + File.open(datafile("memory_profiler_strings.log.#{Time.now.to_i}"), 'w') do |f| curr_strings.sort.each do |s| f.puts s end