summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-09 11:43:41 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-09 11:43:41 -0500
commit0dcbf90ec271350767ef695a5b57877759f7c98f (patch)
treedf60f139ea01fe58110309c18edcfb1179acd403 /src/StardewModdingAPI/Framework
parent69ffdb91b23d37b7c0015cdeb039eec4a48035f0 (diff)
downloadSMAPI-0dcbf90ec271350767ef695a5b57877759f7c98f.tar.gz
SMAPI-0dcbf90ec271350767ef695a5b57877759f7c98f.tar.bz2
SMAPI-0dcbf90ec271350767ef695a5b57877759f7c98f.zip
restore obsolete interfaces for backwards compatibility with EntoFramework
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r--src/StardewModdingAPI/Framework/LogWriter.cs90
1 files changed, 0 insertions, 90 deletions
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
-{
- /// <summary>A log writer which queues messages for output, and periodically flushes them to the console and log file.</summary>
- /// <remarks>Only one instance should be created.</remarks>
- internal class LogWriter
- {
- /*********
- ** Properties
- *********/
- /// <summary>The queued messages to flush.</summary>
- private readonly ConcurrentQueue<LogInfo> Queue;
-
- /// <summary>The underlying file stream.</summary>
- private readonly StreamWriter FileStream;
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="path">The log path to write.</param>
- public LogWriter(string path)
- {
- // create log directory (required for stream writer)
- Directory.CreateDirectory(Path.GetDirectoryName(path));
-
- // initialise
- this.Queue = new ConcurrentQueue<LogInfo>();
- this.FileStream = new StreamWriter(Constants.LogPath, false);
- }
-
- /// <summary>Queue a message for output.</summary>
- /// <param name="message">The message to log.</param>
- public void WriteToLog(string message)
- {
- lock (this.Queue)
- {
- var logEntry = new LogInfo(message);
- this.Queue.Enqueue(logEntry);
-
- if (this.Queue.Any())
- this.FlushLog();
- }
- }
-
- /// <summary>Queue a message for output.</summary>
- /// <param name="message">The message to log.</param>
- public void WriteToLog(LogInfo message)
- {
- lock (this.Queue)
- {
- this.Queue.Enqueue(message);
- if (this.Queue.Any())
- this.FlushLog();
- }
- }
-
-
- /*********
- ** Private methods
- *********/
- /// <summary>Flush the underlying queue to the console and file.</summary>
- 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