private static void WriteLog(HttpContext context) { if (state == LogState.Ready) { try { state = LogState.InProgress; while (queue.Count > 0) { try { WSLogRecord log = queue.Dequeue(); DirectoryInfo dirTo = new DirectoryInfo(WSServerMeta.MapPath(WSConstants.LINKS.LogPath)); if (!Directory.Exists(dirTo.FullName)) { Directory.CreateDirectory(dirTo.FullName); } if (Directory.Exists(dirTo.FullName)) { FileInfo logFile = new FileInfo($"{dirTo}\\{(log.IsError ? "error_" : "")}{ DateTime.Now.ToString("yyyy_MM_dd")}.log"); if (logFile.Exists) { logFile.IsReadOnly = false; } using (TextWriter writer = new StreamWriter(logFile.FullName, logFile.Exists)) { writer.WriteLine($""); writer.WriteLine($"___________{log.date.ToString(WSConstants.DATE_FORMAT)} => New log created [{log.Name}] by [" + (context.Request != null ? context.Request.UserHostAddress : "0.0.0.0") + "]:____________"); foreach (string line in log) { writer.WriteLine("\t-\t" + line); } writer.WriteLine($"____________log end._________________________________________________________________"); writer.WriteLine($""); } logFile = new FileInfo(logFile.FullName); if (logFile.Exists) { logFile.IsReadOnly = true; } } } finally { } } } finally { state = LogState.Ready; } } }
public new void CleanUp() { Request.Dispose(); InnerDispose(); WSServerMeta.CleanUp(); }
protected bool reloadCoreSources() { return(WSServerMeta.reloadCoreSources()); }