forked from brycole/gemstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.lic
64 lines (53 loc) · 1.41 KB
/
log.lic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
=begin
logs the game to lich\logs\<game code>-<char name>\<date>-<number>.log
starts a new file after 30,000 lines (somewhere around 1mb)
author: Tillmen ([email protected])
game: any
version: 0.2
changelog:
0.2 (2015-01-13):
create log directory if needed
=end
unless defined?(script.want_script_output)
echo 'your version of Lich is too old for this script'
exit
end
unless $SAFE == 0
echo 'this script must be trusted to work (;trust log)'
exit
end
hide_me
script.want_script_output = true
script.want_upstream = true
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")}-#{num}.log"
filename = "#{dir}/#{Time.now.strftime("%Y-%m-%d")}-#{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
}