Exemplo n.º 1
0
        private void StartLogging()
        {
            if (Initialized)
            {
                return;
            }

            DLConfigData config = DLConfig.Data;

            try
            {
                SystemUtil.EnsurePathExists(config.ChatlogPath);
                _writer     = new StreamWriter(config.ChatlogPath, append: true);
                Initialized = true;
            }
            catch (Exception e)
            {
                Logger.Error("Error occurred while attempting to initialize the chat logger using path \"" + config.ChatlogPath + "\". Error message: " + e);
            }

            if (Initialized)
            {
                _flushTimer = new Timer(innerArgs =>
                {
                    lock (_overlapLock)
                    {
                        Flush();
                    }
                }, null, 0, CHATLOG_FLUSH_TIMER_INTERAVAL_MS);
            }
        }