Make an instance variable part of TShock so that the Loggers have access to it for using the ServerAPI logger because sometimes the log has been disposed of when we write to it (i.e. other plugins)
This commit is contained in:
parent
5488be0857
commit
7fe761bacb
2 changed files with 9 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using TerrariaApi.Server;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -226,15 +227,17 @@ namespace TShockAPI
|
|||
caller = meth.DeclaringType.Name;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logWriter.WriteLine("{0} - {1}: {2}: {3}",
|
||||
var logEntry = String.Format("{0} - {1}: {2}: {3}",
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||||
caller, level.ToString().ToUpper(), message);
|
||||
try
|
||||
{
|
||||
_logWriter.WriteLine(logEntry);
|
||||
_logWriter.Flush();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
ServerApi.LogWriter.PluginWriteLine(TShock.instance, logEntry, TraceLevel.Error);
|
||||
Console.WriteLine("Unable to write to log as log has been disposed.");
|
||||
Console.WriteLine("{0} - {1}: {2}: {3}",
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue