Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create logxml.lic #6698

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions logxml.lic
Original file line number Diff line number Diff line change
@@ -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(/^<c>/, '')}"
}
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
}