/// <summary> /// Initialize logger /// </summary> /// <param name="internalLogFileName"></param> /// <param name="logLevel"></param> /// <param name="internalLogSync"></param> public void Initialize(string internalLogFileName, LogLevels logLevel, string internalLogSync, bool shouldBeep) { try { LogSyncMode logSync = LogSyncMode.Session; this.LogLevel = logLevel; this.ShouldBeep = shouldBeep; String strLogSync = internalLogSync; if (!string.IsNullOrEmpty(strLogSync)) { if (strLogSync.StartsWith("M", StringComparison.CurrentCultureIgnoreCase)) { logSync = LogSyncMode.Message; } else if (strLogSync.StartsWith("F", StringComparison.CurrentCultureIgnoreCase)) { logSync = LogSyncMode.Flush; } } _logWriter = new FileLogWriter(internalLogFileName, logSync, _logWriter); } catch (Exception e) { WriteDevToLog("ClientManager.init(): " + e.Message); } }
/// <summary> /// Instantiates a new file log writer. /// </summary> /// <param name="fileName">The name of the file to which messages will be written.</param> /// <param name="logSync">The log synchronization mode.</param> /// <param name="fallbackWriter">An ILogWriter that can be used in case the instantiated writer is /// unable to access the target file. This parameter may be null.</param> public FileLogWriter(string fileName, LogSyncMode logSync, ILogWriter fallbackWriter) { this.fallbackWriter = fallbackWriter; logTarget = fileName; if (logSync == LogSyncMode.Message) { closeAfterWrite = true; } else if (logSync != LogSyncMode.Session) { autoFlush = true; } }