diff -r 0f0cf428409f -r d3e36b368fc5 muc_log.vala --- 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("%s", id, _class, id, id, times); + file.printf("%s%s\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("",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("%s", id, _class, id, id, times); - file.printf("%s%s\n", nicklass, nick, str); - file.flush(); + real_write(time, _class, nick, str); } }