public static void Log(string entry)
{
if (console_mode)
{
Console.WriteLine(entry);
}
StreamWriter writer = null;
try
{
FileInfo info = new FileInfo(fileName);
if (info.Exists && (info.Length >= 0x100000))
{
string path = fileName + ".old";
File.Delete(path);
info.MoveTo(path);
}
writer = new StreamWriter(fileName, true);
writer.WriteLine("[{0:yyyy-MM-dd HH:mm:ss}] {1}", DateTime.Now, entry);
writer.Flush();
}
catch (Exception)
{
}
finally
{
if (writer != null)
{
writer.Close();
}
}
}