Catch objectdisposedexception when writing to log file
This commit is contained in:
parent
b85754ee1f
commit
9480b69754
2 changed files with 16 additions and 6 deletions
|
|
@ -160,10 +160,20 @@ namespace TShockAPI
|
|||
caller = meth.DeclaringType.Name;
|
||||
}
|
||||
|
||||
_logWriter.WriteLine(string.Format("{0} - {1}: {2}: {3}",
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||||
caller, level.ToString().ToUpper(), message));
|
||||
_logWriter.Flush();
|
||||
try
|
||||
{
|
||||
_logWriter.WriteLine(string.Format("{0} - {1}: {2}: {3}",
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||||
caller, level.ToString().ToUpper(), message));
|
||||
_logWriter.Flush();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
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),
|
||||
caller, level.ToString().ToUpper(), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,5 +48,5 @@ using System.Runtime.InteropServices;
|
|||
// Build Number
|
||||
// MMdd of the build
|
||||
|
||||
[assembly: AssemblyVersion("3.4.5.0114")]
|
||||
[assembly: AssemblyFileVersion("3.4.5.0114")]
|
||||
[assembly: AssemblyVersion("3.4.5.0115")]
|
||||
[assembly: AssemblyFileVersion("3.4.5.0115")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue