public static bool OpenLogFile() { try { CloseLogFile(); string curpath = Path.Combine(System.Windows.Forms.Application.StartupPath, @"temp");// Path.GetFullPath(".");//Path.GetTempPath(); LogFilePath = curpath; if (!Directory.Exists(curpath)) { Directory.CreateDirectory(curpath); } date = DateTime.Now.ToString("yyyy-MM"); LogFileName = "shadowsocks_" + date + ".log"; LogFile = Path.Combine(curpath, LogFileName); _logFileStream = new FileStream(LogFile, FileMode.Append); _logStreamWriter = new StreamWriterWithTimestamp(_logFileStream); _logStreamWriter.AutoFlush = true; Console.SetOut(_logStreamWriter); Console.SetError(_logStreamWriter); return(true); } catch (IOException e) { Console.WriteLine(e.ToString()); return(false); } }
public static bool OpenLogFile() { try { string curpath = Path.Combine(System.Windows.Forms.Application.StartupPath, @"temp");// Path.GetFullPath(".");//Path.GetTempPath(); if (!Directory.Exists(curpath)) { Directory.CreateDirectory(curpath); } date = DateTime.Now.ToString("yyyy-MM"); LogFile = Path.Combine(curpath, "shadowsocks_" + date + ".log"); FileStream fs = new FileStream(LogFile, FileMode.Append); StreamWriterWithTimestamp sw = new StreamWriterWithTimestamp(fs); sw.AutoFlush = true; Console.SetOut(sw); Console.SetError(sw); return true; } catch (IOException e) { Console.WriteLine(e.ToString()); return false; } }
public static bool OpenLogFile() { try { CloseLogFile(); if (save_to_file) { var newDate = DateTime.Now.ToString("yyyy-MM"); LogFileName = $@"shadowsocks_{newDate}.log"; LogFile = Utils.GetTempPath(LogFileName); _logFileStream = new FileStream(LogFile, FileMode.Append); _logStreamWriter = new StreamWriterWithTimestamp(_logFileStream) { AutoFlush = true }; Console.SetOut(_logStreamWriter); Console.SetError(_logStreamWriter); date = newDate; CompressOldLogFile(); } else { Console.SetOut(DefaultOut); Console.SetError(DefaultError); } return(true); } catch (IOException e) { Console.WriteLine(e.ToString()); return(false); } }
private static void CloseLogFile() { _logStreamWriter?.Dispose(); _logFileStream?.Dispose(); _logStreamWriter = null; _logFileStream = null; }
public static void CloseLogFile(bool closed = true) { if (closed) { enabled = false; } _logStreamWriter?.Dispose(); _logFileStream?.Dispose(); _logStreamWriter = null; _logFileStream = null; }
private static void CloseLogFile() { if (_logStreamWriter != null) { _logStreamWriter.Dispose(); _logStreamWriter = null; } if (_logFileStream != null) { _logFileStream.Dispose(); _logFileStream = null; } }
public static bool OpenLogFile() { try { LogFile = Path.Combine(Path.GetTempPath(), "shadowsocks.log"); var fs = new FileStream(LogFile, FileMode.Append); var sw = new StreamWriterWithTimestamp(fs) {AutoFlush = true}; Console.SetOut(sw); Console.SetError(sw); return true; } catch (IOException e) { Console.WriteLine(e.ToString()); return false; } }
public static bool OpenLogFile() { try { LogFile = Utils.GetTempPath("shadowsocks.log"); FileStream fs = new FileStream(LogFile, FileMode.Append); StreamWriterWithTimestamp sw = new StreamWriterWithTimestamp(fs); sw.AutoFlush = true; Console.SetOut(sw); Console.SetError(sw); return(true); } catch (IOException e) { Console.WriteLine(e.ToString()); return(false); } }
public static bool OpenLogFile() { try { string temppath = Utils.GetTempPath(); LogFile = Path.Combine(temppath, "shadowsocks.log"); FileStream fs = new FileStream(LogFile, FileMode.Append); StreamWriterWithTimestamp sw = new StreamWriterWithTimestamp(fs); sw.AutoFlush = true; Console.SetOut(sw); Console.SetError(sw); return true; } catch (IOException e) { Console.WriteLine(e.ToString()); return false; } }
public static bool OpenLogFile() { try { LogFilePath = Path.Combine(Path.GetTempPath(), "shadowsocks.log"); _fs = new FileStream(LogFilePath, FileMode.Append); _sw = new StreamWriterWithTimestamp(_fs); _sw.AutoFlush = true; Console.SetOut(_sw); Console.SetError(_sw); return(true); } catch (IOException e) { Console.WriteLine(e.ToString()); return(false); } }
public static bool OpenLogFile() { try { string curpath = Path.Combine(System.Windows.Forms.Application.StartupPath, @"temp");// Path.GetFullPath(".");//Path.GetTempPath(); if (!Directory.Exists(curpath)) { Directory.CreateDirectory(curpath); } LogFile = Path.Combine(curpath, "shadowsocks.log"); FileStream fs = new FileStream(LogFile, FileMode.Append); StreamWriterWithTimestamp sw = new StreamWriterWithTimestamp(fs); sw.AutoFlush = true; Console.SetOut(sw); Console.SetError(sw); return(true); } catch (IOException e) { Console.WriteLine(e.ToString()); return(false); } }
public static bool OpenLogFile() { try { CloseLogFile(); string new_date = DateTime.Now.ToString("yyyy-MM"); LogFileName = "shadowsocks_" + new_date + ".log"; LogFile = AppdataPath.Current.GetFilePath(LogFileName); _logFileStream = new FileStream(LogFile, FileMode.Append); _logStreamWriter = new StreamWriterWithTimestamp(_logFileStream); _logStreamWriter.AutoFlush = true; Console.SetOut(_logStreamWriter); Console.SetError(_logStreamWriter); date = new_date; return(true); } catch (IOException e) { Console.WriteLine(e.ToString()); return(false); } }
public static bool OpenLogFile() { try { LogFilePath = Utils.GetTempPath("shadowsocks.log"); _fs = new FileStream(LogFilePath, FileMode.Append); _sw = new StreamWriterWithTimestamp(_fs); _sw.AutoFlush = true; Console.SetOut(_sw); Console.SetError(_sw); return true; } catch (IOException e) { Console.WriteLine(e.ToString()); return false; } }