添加了读日志

This commit is contained in:
zxd 2018-08-03 11:43:10 +08:00
parent 4469ebe8f4
commit c37f276314
4 changed files with 19 additions and 1 deletions

View File

@ -44,6 +44,12 @@ namespace Plane.Logging
}
}
public override string ReadLog()
{
string text = File.ReadAllText(LogFilePath);
return text;
}
protected override void LogCore(string message, Category category, Priority priority)
{
lock (_logLock)

View File

@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
namespace Plane.Logging
{
@ -16,5 +17,11 @@ namespace Plane.Logging
{
Debug.WriteLine(BuildStandardLogEntry(message, category, priority)); //写入日志
}
public override string ReadLog()
{
return "";
}
}
}

View File

@ -18,5 +18,7 @@ namespace Plane.Logging
/// <param name="category">Category of the entry.</param>
/// <param name="priority">The priority of the entry.</param>
void Log(string message, Category category = Category.Info, Priority priority = Priority.None);
string ReadLog();
}
}

View File

@ -26,6 +26,9 @@ namespace Plane.Logging
LogCore(message, category, priority);
}
public abstract string ReadLog();
protected static string BuildStandardLogEntry(string message, Category category, Priority priority)
{
return $"--{category}-{priority}-{DateTime.Now.ToString("yyyyMMdd HH:mm:ss.fff")}--------------------{Environment.NewLine}{Environment.NewLine}{message}{Environment.NewLine}{Environment.NewLine}--<END>--{Environment.NewLine}{Environment.NewLine}";