static string DatedFilepath(string path, DateTimeOffset date, LogRotateSchedule schedule) { const string seperator = " "; const string extension = ".txt"; string dateFmt = null; switch (schedule) { case LogRotateSchedule.Yearly: dateFmt = "yyyy"; break; case LogRotateSchedule.Monthly: dateFmt = "yyyy-MM"; break; case LogRotateSchedule.Daily: dateFmt = "yyyy-MM-dd"; break; } if (dateFmt != null) { return(path + seperator + date.ToString(dateFmt) + extension); } else { return(path + extension); } }
public ChatlogMetaData( string basePath, string ircEntity, LogRotateSchedule schedule, DateTimeOffset now) { barePath = Path.Combine( basePath, // Sanitize name of irc entity so it's a valid filename. // This will probably be expanded in the future. ircEntity.Replace('/', '_') ); Schedule = schedule; LogfilePath = DatedFilepath(barePath, now, schedule); LastWrite = DateTimeOffset.MaxValue; }