#
# file:: cmd_syslog.rb
# This source code copyright (C) 2009 Craig Smith
# All rights reserved.
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#
module Cmd
bindtextdomain("cmd")
# Shows the system log
def cmd_syslog(args)
sendto("Loading log file...")
max = 20
max = args.to_i if args.to_i > 0
lines = []
File.open(options['logfile'], "r").each { |l| lines << l }
revlines = []
cnt = 1
lines.reverse.each do |l|
if not l=~/\[DEBUG\]/
if cnt <= max
revlines << l
end
cnt += 1
end
end
msg = ""
revlines.reverse.each do |l|
if l.size > 70
msg << "#{l[0,67]}...\n"
else
msg << l
end
end
if msg.size > 0
msg = Msg.new(msg)
msg.no_parse = true
sendto(msg)
else
sendto _("No messages in syslog.")
end
end
end