From 0dcbf90ec271350767ef695a5b57877759f7c98f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 9 Nov 2016 11:43:41 -0500 Subject: restore obsolete interfaces for backwards compatibility with EntoFramework --- src/StardewModdingAPI/Framework/LogWriter.cs | 90 ---------------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/StardewModdingAPI/Framework/LogWriter.cs (limited to 'src/StardewModdingAPI/Framework/LogWriter.cs') diff --git a/src/StardewModdingAPI/Framework/LogWriter.cs b/src/StardewModdingAPI/Framework/LogWriter.cs deleted file mode 100644 index c21d53f4..00000000 --- a/src/StardewModdingAPI/Framework/LogWriter.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.IO; -using System.Linq; - -namespace StardewModdingAPI.Framework -{ - /// A log writer which queues messages for output, and periodically flushes them to the console and log file. - /// Only one instance should be created. - internal class LogWriter - { - /********* - ** Properties - *********/ - /// The queued messages to flush. - private readonly ConcurrentQueue Queue; - - /// The underlying file stream. - private readonly StreamWriter FileStream; - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The log path to write. - public LogWriter(string path) - { - // create log directory (required for stream writer) - Directory.CreateDirectory(Path.GetDirectoryName(path)); - - // initialise - this.Queue = new ConcurrentQueue(); - this.FileStream = new StreamWriter(Constants.LogPath, false); - } - - /// Queue a message for output. - /// The message to log. - public void WriteToLog(string message) - { - lock (this.Queue) - { - var logEntry = new LogInfo(message); - this.Queue.Enqueue(logEntry); - - if (this.Queue.Any()) - this.FlushLog(); - } - } - - /// Queue a message for output. - /// The message to log. - public void WriteToLog(LogInfo message) - { - lock (this.Queue) - { - this.Queue.Enqueue(message); - if (this.Queue.Any()) - this.FlushLog(); - } - } - - - /********* - ** Private methods - *********/ - /// Flush the underlying queue to the console and file. - private void FlushLog() - { - lock (this.FileStream) - { - LogInfo entry; - while (this.Queue.TryDequeue(out entry)) - { - string message = $"[{entry.LogTime}] {entry.Message}"; - - if (entry.PrintConsole) - { - Console.ForegroundColor = entry.Colour; - Console.WriteLine(message); - Console.ForegroundColor = ConsoleColor.Gray; - } - - this.FileStream.WriteLine(message); - } - this.FileStream.Flush(); - } - } - } -} \ No newline at end of file -- cgit