From a555772323e1c8129db0f2db82592f1156aa0cfb Mon Sep 17 00:00:00 2001 From: Briarleigh <77058868+Kiriawen@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:21:47 -0500 Subject: [PATCH] Create logxml.lic adding logxml to the repo --- logxml.lic | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 logxml.lic diff --git a/logxml.lic b/logxml.lic new file mode 100644 index 0000000000..e9eb372e20 --- /dev/null +++ b/logxml.lic @@ -0,0 +1,60 @@ +=begin + +Script to log the downstream XML. + +Hacked from Tillmen's log script. + + +=end + + + +script.want_downstream=false +script.want_downstream_xml = true + +script.want_script_output = true +script.want_upstream = true + + +unless $SAFE == 0 + echo 'this script must be trusted to work (;trust logxml)' + exit +end + +hide_me + + +Thread.new { + begin + loop { + script.downstream_buffer.push ">#{upstream_get.sub(/^/, '')}" + } + rescue + echo $! + end +} + +Dir.mkdir("#{$lich_dir}logs") unless File.exists?("#{$lich_dir}logs") +dir = "#{$lich_dir}logs/#{XMLData.game}-#{XMLData.name}" +Dir.mkdir(dir) unless File.exists?(dir) + +loop { + num = 1 + filename = "#{dir}/#{Time.now.strftime("%Y-%m-%d")}-xml-#{num}.log" + filename = "#{dir}/#{Time.now.strftime("%Y-%m-%d")}-xml-#{num+=1}.log" while File.exists?(filename) + file = File.open(filename, 'a') + file.sync = true + file.puts "#{Time.now.strftime("%Y-%m-%d %I:%M%P").sub(/0([0-9]+\:)/) {"#{$1}"}}\n" + file.puts(reget) if (Time.now - $login_time) < 30 + begin + 30000.times { + line = get +# unless line =~ /^<(?:push|pop)Stream/ + file.puts line +# end + } + file.puts "#{Time.now.strftime("%Y-%m-%d %I:%M%P").sub(/0([0-9]+\:)/) {"#{$1}"}}\n" + ensure + file.close rescue() + end +}