Files
RobustToolbox/Robust.Shared/Log/FileLogHandler.cs
T
SilverandGitHub 25926a17b7 Renames SS14.* to Robust.* (#793)
RobustToolbox projects should be named Robust.* 

This PR changes the RobustToolbox projects from SS14.* to Robust.*

Updates SS14.* prefixes/namespaces to Robust.*
Updates SpaceStation14.sln to RobustToolbox.sln
Updates MSBUILD/SS14.* to MSBUILD/Robust.*
Updates CSProject and MSBuild references for the above
Updates git_helper.py
Removes Runserver and Runclient as they are unusable
2019-04-15 20:24:59 -06:00

35 lines
968 B
C#

using Robust.Shared.Interfaces.Log;
using System;
using System.IO;
using System.Text;
using Robust.Shared.Utility;
namespace Robust.Shared.Log
{
public sealed class FileLogHandler : ILogHandler, IDisposable
{
private readonly TextWriter writer;
public FileLogHandler(string path)
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
writer = TextWriter.Synchronized(new StreamWriter(path, true, EncodingHelpers.UTF8));
}
public void Dispose()
{
writer.Dispose();
}
public void Log(in LogMessage message)
{
var name = message.LogLevelToName();
writer.WriteLine("{0:o} [{1}] {2}: {3}", DateTime.Now, name, message.SawmillName, message.Message);
// This probably isn't the best idea.
// Remove this flush if it becomes a problem (say performance).
writer.Flush();
}
}
}