--- a/muc_log.vala Mon Nov 05 23:53:52 2012 +0400
+++ b/muc_log.vala Mon Nov 05 23:54:44 2012 +0400
@@ -35,12 +35,26 @@
}
return ((sum ^ m)+l)%10;
}
+
+ protected void real_write(Time time, string _class, string nick, string str) {
+ var id = getid(time);
+ var times = time.format("%H:%M:%S");
+ var nicklass = (_class=="message") ? (" nick%u".printf(nick_hash(nick))) : "";
+
+ file.printf("<tr id='l_%s' class='%s'><td class='time'><a id='i_%s' href='#i_%s'>%s</a></td>", id, _class, id, id, times);
+ file.printf("<td class='nick%s'>%s</td><td class='text'>%s</td></tr>\n", nicklass, nick, str);
+ file.flush();
+ }
+
public void write(Time time, string _class, string nick, string str) {
-
if ((lastday != time.day)||(lastmonth != time.month)||(lastyear!=time.year)) {
var fname = time.format(logpath).replace("<muc>",jid);
log("muc_log", LogLevelFlags.LEVEL_INFO, "Switching log file '%s' to '%s'", filename, fname);
- if (file!=null) file.flush();
+ bool wasntnull = false;
+ if (file!=null) {
+ wasntnull = true;
+ real_write(time, "logstop", "", "Log stopped. See you in the next episode.");
+ }
//try {
file = FileStream.open(fname,"a");
if (file==null) {
@@ -79,15 +93,11 @@
}
filename = fname;
lastyear = time.year; lastmonth = time.month; lastday = time.day;
+ if (wasntnull)
+ real_write(time, "logstart", "", "Log started. This soap opera will never end.");
}
-
- var id = getid(time);
- var times = time.format("%H:%M:%S");
- var nicklass = (_class=="message") ? (" nick%u".printf(nick_hash(nick))) : "";
- file.printf("<tr id='l_%s' class='%s'><td class='time'><a id='i_%s' href='#i_%s'>%s</a></td>", id, _class, id, id, times);
- file.printf("<td class='nick%s'>%s</td><td class='text'>%s</td></tr>\n", nicklass, nick, str);
- file.flush();
+ real_write(time, _class, nick, str);
}
}