Skip to content

Commit

Permalink
Fix SystemLog (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang authored Apr 16, 2020
1 parent d62b18b commit 14f3f4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/SystemLog/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Text;
using static System.IO.Path;

namespace Neo.Plugins
Expand Down Expand Up @@ -39,7 +40,10 @@ void ILogPlugin.Log(string source, LogLevel level, string message)

if (!string.IsNullOrEmpty(Settings.Default.Path))
{
var path = Combine(Settings.Default.Path, source);
StringBuilder sb = new StringBuilder(source);
foreach (char c in GetInvalidFileNameChars())
sb.Replace(c, '-');
var path = Combine(Settings.Default.Path, sb.ToString());
Directory.CreateDirectory(path);
path = Combine(path, $"{now:yyyy-MM-dd}.log");
File.AppendAllLines(path, new[] { $"[{level}]{log}" });
Expand Down

0 comments on commit 14f3f4b

Please sign in to comment.