OSDN Git Service

Revisit(er) & ReadOnly chunk use
[automap/automap.git] / ShardProcessor / LogAdaptor.cs
1 using System;
2 using System.IO;
3
4 using Vintagestory.API.Common;
5
6 namespace ShardProcessor
7 {
8         public class LogAdaptor : LoggerBase
9         {
10                 private StreamWriter fileOutput;
11
12                 public LogAdaptor( )
13                 {
14                 fileOutput = File.CreateText("SP_Log.txt");
15                 fileOutput.AutoFlush = true;            
16                 }
17
18                 protected override void LogImpl(EnumLogType logType, string format, params object[ ] args)
19                 {
20                 string formatedText = null;
21                 if (args != null && args.Length > 0) {
22                 formatedText = string.Format(format, args);
23                 }
24                 else { formatedText = format; }
25
26                 fileOutput.WriteLine($"«{logType}» {formatedText}");                          
27                 }
28
29                 ~LogAdaptor( )
30                 {
31                 fileOutput.Flush( );
32                 fileOutput.Close( );                              
33                 }
34         }
35 }
36