Beispiel #1
0
        public override void LogText(DateTime timeStamp, LogLevel logLevel, string s)
        {
            lock (_fileLock)
            {
                string fn = GenerateFileName();

                string timePart = FormatTime(timeStamp);

                s = s.Replace("\r", "").Replace("\n", "\n" + new string(' ', timePart.Length + 3)).Replace("\n", "\r\n");

                s = $"{timePart} | {s}";

                for (int i = 0; i < 10; i++)
                {
                    try
                    {
                        FileIO.AppendAllText(fn, s + "\r\n");

                        break;
                    }
                    catch (IOException)
                    {
                        Task.Delay(100).Wait();
                    }
                }

                LastUsedFileName = fn;

                RemoveOldFiles();
            }
        }