Skip to content

Commit

Permalink
Fix missing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoburatto committed Sep 21, 2023
1 parent 2183508 commit c727f93
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
26 changes: 11 additions & 15 deletions Assets/Scripts/SS3D/Core/LogManager.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
using Serilog;
using Serilog.Sinks.Unity3D;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting.Compact;
using UnityEngine;
using FishNet;
using System;
using System.Linq;
using System.Collections.Generic;
using SS3D.Logging.LogSettings;
using SS3D.Logging;
using SS3D.Data;
using FishNet.Configuring;
using Log = Serilog.Log;


Expand All @@ -25,28 +21,28 @@ namespace SS3D.Core
/// </summary>
public static class LogManager
{
private static readonly string defaultUnityLogTemplate;
private static readonly string DefaultUnityLogTemplate;
private static readonly string LogFolderPath;
private static bool _isInitialized;
private static bool IsInitialized;

private static LogSettings settings;
private static readonly LogSettings Settings;

static LogManager()
{
defaultUnityLogTemplate = "{SourceContext} {Message}{NewLine}{Exception}";
DefaultUnityLogTemplate = "{SourceContext} {Message}{NewLine}{Exception}";
LogFolderPath = Application.dataPath + "/../Logs/";

if (Application.isPlaying)
{
settings = Assets.Get<LogSettings>(Data.Enums.AssetDatabases.Settings, (int)Data.Enums.SettingsId.LogSettings);
Settings = Assets.Get<LogSettings>(Data.Enums.AssetDatabases.Settings, (int)Data.Enums.SettingsId.LogSettings);
}

}

public static void Initialize()
{
if (_isInitialized) return;
_isInitialized = true;
if (IsInitialized) return;
IsInitialized = true;

var configuration = new LoggerConfiguration();

Expand All @@ -56,7 +52,7 @@ public static void Initialize()
}

// Configure writing to Unity's console, using our custom text formatter.
configuration = configuration.WriteTo.Unity3D(formatter: new SS3DUnityTextFormatter(outputTemplate: defaultUnityLogTemplate));
configuration = configuration.WriteTo.Unity3D(formatter: new SS3DUnityTextFormatter(outputTemplate: DefaultUnityLogTemplate));



Expand All @@ -79,9 +75,9 @@ private static LoggerConfiguration ConfigureForPlayMode(LoggerConfiguration conf

// Apply some override on the minimum logging level for some namespaces using the log settings.
// Does not apply override if the logging level corresponds to the global minimum level.
foreach (var levelForNameSpace in settings.SS3DNameSpaces)
foreach (var levelForNameSpace in Settings.SS3DNameSpaces)
{
if (levelForNameSpace.Level == settings.defaultLogLevel) continue;
if (levelForNameSpace.Level == Settings.defaultLogLevel) continue;

configuration = configuration.MinimumLevel.Override(levelForNameSpace.Name, levelForNameSpace.Level);
}
Expand Down Expand Up @@ -112,7 +108,7 @@ private static LoggerConfiguration ConfigureForPlayMode(LoggerConfiguration conf
/// </summary>
private static LoggerConfiguration ConfigureMinimumLevel(LoggerConfiguration loggerConfiguration)
{
switch (settings.defaultLogLevel)
switch (Settings.defaultLogLevel)
{
case LogEventLevel.Verbose: return loggerConfiguration.MinimumLevel.Verbose();
case LogEventLevel.Debug: return loggerConfiguration.MinimumLevel.Debug();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private void HandleStoredItemsChanged(SyncListOperation op, int index, StoredIte
}

// This seem to be called correctly 2 move and none when moving inside, 2 remove and none when removing, 2 add and none when adding, 2 add 2 remove and none when transferring
Punpun.Information(this, "container change type is" + changeType.ToString());
Log.Information(this, "container change type is" + changeType.ToString());

if (changeType == ContainerChangeType.None) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ private void CmdTransferItem(GameObject itemObject, Vector2Int position, Attache

// Can't put an item in its own container
if (item.GetComponentsInChildren<AttachedContainer>().AsEnumerable().Contains(container)){
Punpun.Warning(this, "can't put an item in its own container");
Log.Warning(this, "can't put an item in its own container");
return;
}

if (container == null)
{
Punpun.Error(this, $"Client sent invalid container reference: NetId {container.ObjectId}");
Log.Error(this, $"Client sent invalid container reference: NetId {container.ObjectId}");
return;
}

Expand Down

0 comments on commit c727f93

Please sign in to comment.