Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
66
Scripts/Misc/Timestamp.cs
Normal file
66
Scripts/Misc/Timestamp.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace System
|
||||
{
|
||||
public class ConsoleHook : TextWriter
|
||||
{
|
||||
#if DEBUG
|
||||
private static readonly bool _Enabled = false;
|
||||
#else
|
||||
private static readonly bool _Enabled = true;
|
||||
#endif
|
||||
|
||||
private static Stream m_OldOutput;
|
||||
private static bool m_Newline;
|
||||
public override Encoding Encoding
|
||||
{
|
||||
get
|
||||
{
|
||||
return Encoding.ASCII;
|
||||
}
|
||||
}
|
||||
private string Timestamp
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Format("{0:D2}:{1:D2}:{2:D2} ", DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second);
|
||||
}
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
if (_Enabled)
|
||||
{
|
||||
m_OldOutput = Console.OpenStandardOutput();
|
||||
Console.SetOut(new ConsoleHook());
|
||||
m_Newline = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteLine(string value)
|
||||
{
|
||||
if (m_Newline)
|
||||
{
|
||||
value = this.Timestamp + value;
|
||||
}
|
||||
|
||||
byte[] data = this.Encoding.GetBytes(value);
|
||||
m_OldOutput.Write(data, 0, data.Length);
|
||||
m_OldOutput.WriteByte(10);
|
||||
m_Newline = true;
|
||||
}
|
||||
|
||||
public override void Write(string value)
|
||||
{
|
||||
if (m_Newline)
|
||||
{
|
||||
value = this.Timestamp + value;
|
||||
}
|
||||
|
||||
byte[] data = this.Encoding.GetBytes(value);
|
||||
m_OldOutput.Write(data, 0, data.Length);
|
||||
m_Newline = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user