chore(logging): Logging cleanup (#580)
This commit is contained in:
parent
c6cbda6f52
commit
9f9d990f85
9 changed files with 32 additions and 47 deletions
|
|
@ -14,8 +14,8 @@ namespace Benchmarks
|
|||
private Logger logger;
|
||||
private Logger asyncLogger;
|
||||
|
||||
[IterationSetup]
|
||||
public void IterationSetup()
|
||||
[GlobalSetup]
|
||||
public void GlobalSetup()
|
||||
{
|
||||
logger = new LoggerConfiguration()
|
||||
.WriteTo.Console()
|
||||
|
|
@ -26,8 +26,8 @@ namespace Benchmarks
|
|||
.CreateLogger();
|
||||
}
|
||||
|
||||
[IterationCleanup]
|
||||
public void IterationCleanup()
|
||||
[GlobalCleanup]
|
||||
public void GlobalCleanup()
|
||||
{
|
||||
logger = null;
|
||||
asyncLogger = null;
|
||||
|
|
@ -36,7 +36,7 @@ namespace Benchmarks
|
|||
[Benchmark]
|
||||
public void TestConsoleWriteLine()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ namespace Benchmarks
|
|||
[Benchmark]
|
||||
public void TestSerilogConsoleSink()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
logger.Information(text);
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ namespace Benchmarks
|
|||
[Benchmark]
|
||||
public void TestSerilogAsyncConsoleSink()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
asyncLogger.Information(text);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Logging;
|
||||
using Server.Network;
|
||||
using Server.Utilities;
|
||||
using QueuePool = Server.Utilities.RefPool<Server.Utilities.QueueRef<Server.Items.Container>>;
|
||||
|
|
@ -1822,6 +1823,8 @@ namespace Server.Items
|
|||
|
||||
public class ContainerData
|
||||
{
|
||||
private static ILogger _logger;
|
||||
private static ILogger Logger => _logger ??= LogFactory.GetLogger(typeof(ContainerData));
|
||||
private static readonly Dictionary<int, ContainerData> m_Table;
|
||||
|
||||
static ContainerData()
|
||||
|
|
@ -1886,7 +1889,7 @@ namespace Server.Items
|
|||
|
||||
if (m_Table.ContainsKey(id))
|
||||
{
|
||||
Console.WriteLine(@"Warning: double ItemID entry in Data\containers.cfg");
|
||||
Logger.Warning("double ItemID entry in Data\\containers.cfg");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ namespace Server
|
|||
{
|
||||
ClosingTokenSource.Cancel();
|
||||
|
||||
Console.Write("Core: Shutting down...");
|
||||
logger.Information("Shutting down");
|
||||
|
||||
World.WaitForWriteCompletion();
|
||||
|
||||
|
|
@ -353,8 +353,6 @@ namespace Server
|
|||
}
|
||||
|
||||
Timer.TimerThread.Set();
|
||||
|
||||
Console.WriteLine("done");
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Logging;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -268,12 +270,14 @@ namespace Server
|
|||
{
|
||||
public const int SectorSize = 16;
|
||||
public const int SectorShift = 4;
|
||||
public static readonly int SectorActiveRange = 2;
|
||||
public const int SectorActiveRange = 2;
|
||||
|
||||
private static readonly Queue<List<Item>> m_FixPool = new(128);
|
||||
|
||||
private static readonly List<Item> m_EmptyFixItems = new();
|
||||
|
||||
private static ILogger _logger;
|
||||
private static ILogger Logger => _logger ??= LogFactory.GetLogger(typeof(Map));
|
||||
|
||||
private readonly int m_FileIndex;
|
||||
private readonly Sector[][] m_Sectors;
|
||||
private readonly int m_SectorsHeight;
|
||||
|
|
@ -360,8 +364,7 @@ namespace Server
|
|||
{
|
||||
if (this == Internal && m_Name != "Internal")
|
||||
{
|
||||
Console.WriteLine("Internal Map Name was changed to '{0}'", m_Name);
|
||||
|
||||
Logger.Warning($"Internal map name was '{m_Name}'\n{new StackTrace()}");
|
||||
m_Name = "Internal";
|
||||
}
|
||||
|
||||
|
|
@ -371,7 +374,7 @@ namespace Server
|
|||
{
|
||||
if (this == Internal && value != "Internal")
|
||||
{
|
||||
Console.WriteLine("Attempted to set Internal Map Name to '{0}'", value);
|
||||
Logger.Warning($"Attempted to set internal map name to '{value}'\n{new StackTrace()}");
|
||||
|
||||
value = "Internal";
|
||||
}
|
||||
|
|
@ -967,7 +970,7 @@ namespace Server
|
|||
|
||||
if (Regions.ContainsKey(regName))
|
||||
{
|
||||
Console.WriteLine("Warning: Duplicate region name '{0}' for map '{1}'", regName, Name);
|
||||
Logger.Warning($"Duplicate region name '{regName}' for map '{Name}'");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1024,7 +1027,7 @@ namespace Server
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Warning: Invalid object ({0}) in line of sight", o);
|
||||
Logger.Warning($"Warning: Invalid object ({o}) in line of sight");
|
||||
p = Point3D.Zero;
|
||||
}
|
||||
|
||||
|
|
@ -1382,14 +1385,6 @@ namespace Server
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*if (t.Z <= point.Z && t.Z+height >= point.Z && (flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0
|
||||
&& ( (flags&TileFlag.Wall)!=0 || (flags&TileFlag.Roof)!=0 || (((flags&TileFlag.Surface)!=0 && zd != 0)) ) )*/
|
||||
/*{
|
||||
//Console.WriteLine( "LoS: Blocked by Static \"{0}\" Z:{1} T:{3} P:{2} F:x{4:X}", TileData.ItemTable[t.ID&TileData.MaxItemValue].Name, t.Z, point, t.Z+height, flags );
|
||||
//Console.WriteLine( "if ({0} && {1} && {2} && ( {3} || {4} || {5} || ({6} && {7} && {8}) ) )", t.Z <= point.Z, t.Z+height >= point.Z, (flags&TileFlag.Window)==0, (flags&TileFlag.Impassable)!=0, (flags&TileFlag.Wall)!=0, (flags&TileFlag.Roof)!=0, (flags&TileFlag.Surface)!=0, t.Z != dest.Z, zd != 0 ) ;
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1447,17 +1442,6 @@ namespace Server
|
|||
|
||||
area.Free();
|
||||
return false;
|
||||
|
||||
/*if ((flags & (TileFlag.Impassable | TileFlag.Surface | TileFlag.Roof)) != 0)
|
||||
|
||||
//flags = TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Flags;
|
||||
//if ((flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0 && ( (flags&TileFlag.Wall)!=0 || (flags&TileFlag.Roof)!=0 || (((flags&TileFlag.Surface)!=0 && zd != 0)) ))
|
||||
{
|
||||
//height = TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Height;
|
||||
//Console.WriteLine( "LoS: Blocked by ITEM \"{0}\" P:{1} T:{2} F:x{3:X}", TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Name, i.Location, i.Location.Z+height, flags );
|
||||
area.Free();
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
area.Free();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using Server.Diagnostics;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,9 +59,15 @@ namespace Server
|
|||
|
||||
_map = owner;
|
||||
|
||||
#if DEBUG
|
||||
const bool warnNotFound = true;
|
||||
#else
|
||||
const bool warnNotFound = false;
|
||||
#endif
|
||||
|
||||
if (fileIndex != 0x7F)
|
||||
{
|
||||
var mapPath = Core.FindDataFile($"map{fileIndex}.mul", false);
|
||||
var mapPath = Core.FindDataFile($"map{fileIndex}.mul", false, warnNotFound);
|
||||
|
||||
if (mapPath != null)
|
||||
{
|
||||
|
|
@ -69,7 +75,7 @@ namespace Server
|
|||
}
|
||||
else
|
||||
{
|
||||
mapPath = Core.FindDataFile($"map{fileIndex}LegacyMUL.uop", false, true);
|
||||
mapPath = Core.FindDataFile($"map{fileIndex}LegacyMUL.uop", false, warnNotFound);
|
||||
|
||||
if (mapPath != null)
|
||||
{
|
||||
|
|
@ -78,7 +84,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
var indexPath = Core.FindDataFile($"staidx{fileIndex}.mul", false, true);
|
||||
var indexPath = Core.FindDataFile($"staidx{fileIndex}.mul", false, warnNotFound);
|
||||
|
||||
if (indexPath != null)
|
||||
{
|
||||
|
|
@ -86,7 +92,7 @@ namespace Server
|
|||
IndexReader = new BinaryReader(IndexStream);
|
||||
}
|
||||
|
||||
var staticsPath = Core.FindDataFile($"statics{fileIndex}.mul", false, true);
|
||||
var staticsPath = Core.FindDataFile($"statics{fileIndex}.mul", false, warnNotFound);
|
||||
|
||||
if (staticsPath != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Server.Logging;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue