// Decompiled with JetBrains decompiler // Type: CarotDAV.LogWriter // Assembly: CarotDAV, Version=1.13.2.18337, Culture=neutral, PublicKeyToken=null // MVID: C31F2651-A4A8-4D09-916A-8C6106F5E7C8 // Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\CarotDAV.exe using Microsoft.VisualBasic.CompilerServices; using System; using System.IO; using System.Runtime.CompilerServices; using System.Text; using System.Threading; namespace CarotDAV { public class LogWriter { private static object pSyncObject = RuntimeHelpers.GetObjectValue(new object()); private static bool pEnabled = false; private static string pLogFilePath; public static string LogFilePath { get { object pSyncObject = LogWriter.pSyncObject; ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject); Monitor.Enter(pSyncObject); try { return LogWriter.pLogFilePath; } finally { Monitor.Exit(pSyncObject); } } set { if (value != null && value.Length == 0) value = (string) null; object pSyncObject = LogWriter.pSyncObject; ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject); Monitor.Enter(pSyncObject); try { LogWriter.pLogFilePath = value; } finally { Monitor.Exit(pSyncObject); } } } public static bool Enabled { get { object pSyncObject = LogWriter.pSyncObject; ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject); Monitor.Enter(pSyncObject); try { return LogWriter.pEnabled; } finally { Monitor.Exit(pSyncObject); } } set { object pSyncObject = LogWriter.pSyncObject; ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject); Monitor.Enter(pSyncObject); try { LogWriter.pEnabled = value; } finally { Monitor.Exit(pSyncObject); } } } public static void ClearLog() { try { File.Delete(LogWriter.LogFilePath); } catch (Exception ex) { ProjectData.SetProjectError(ex); ProjectData.ClearProjectError(); } } public static void WriteException(Exception ex) { LogWriter.WriteMessage("Exception", ex.ToString() + "---" + ex.Message + "\r\n" + ex.StackTrace); } public static void WriteNotification(string message) { LogWriter.WriteMessage("Notification", message); } public static void WriteMessage(string type, string message) { LogWriter.InternalWriteLine(string.Join("", new string[7] { "[", type, "]", " ", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), " ", message })); } protected static void InternalWriteLine(string message) { object pSyncObject = LogWriter.pSyncObject; ObjectFlowControl.CheckForSyncLockOnValueType(pSyncObject); Monitor.Enter(pSyncObject); try { if (!LogWriter.pEnabled) return; if (LogWriter.pLogFilePath == null) return; try { using (StreamWriter streamWriter = new StreamWriter(LogWriter.pLogFilePath, true, Encoding.UTF8)) streamWriter.WriteLine(message); } catch (Exception ex) { ProjectData.SetProjectError(ex); ProjectData.ClearProjectError(); } } finally { Monitor.Exit(pSyncObject); } } } }