Skip to content

Commit

Permalink
Update loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed May 6, 2024
1 parent 6bd3924 commit 5421dea
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Fika.Core/AkiSupport/Airdrops/Utils/FikaItemFactoryUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class FikaItemFactoryUtil
public FikaItemFactoryUtil()
{
itemFactory = Singleton<ItemFactory>.Instance;
logSource = new("ItemFactoryUtil");
logSource = Logger.CreateLogSource("ItemFactoryUtil");
}

public void BuildContainer(LootableContainer container, FikaAirdropConfigModel config, string dropType)
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/BTR/FikaBTRManager_Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class FikaBTRManager_Client : MonoBehaviour
Type btrControllerType = typeof(BTRControllerClass);
_updateTaxiPriceMethod = AccessTools.GetDeclaredMethods(btrControllerType).Single(IsUpdateTaxiPriceMethod);
client = Singleton<FikaClient>.Instance;
btrLogger = new("BTR Client");
btrLogger = BepInEx.Logging.Logger.CreateLogSource("BTR Client");
}

private void Awake()
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/BTR/FikaBTRManager_Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal class FikaBTRManager_Host : MonoBehaviour
Type btrControllerType = typeof(BTRControllerClass);
_updateTaxiPriceMethod = AccessTools.GetDeclaredMethods(btrControllerType).Single(IsUpdateTaxiPriceMethod);
server = Singleton<FikaServer>.Instance;
btrLogger = new("BTR Host");
btrLogger = BepInEx.Logging.Logger.CreateLogSource("BTR Host");
}

public bool CanPlayerEnter(IPlayer player)
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/PacketHandlers/ServerPacketSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ServerPacketSender : MonoBehaviour, IPacketSender

private void Awake()
{
logger = new("ServerPacketSender");
logger = BepInEx.Logging.Logger.CreateLogSource("ServerPacketSender");
player = GetComponent<CoopPlayer>();
}

Expand Down
3 changes: 1 addition & 2 deletions Fika.Core/Networking/FikaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ public NetManager NetClient
public string IP { get; private set; }
public int Port { get; private set; }
public bool SpawnPointsReceived { get; private set; } = false;
private ManualLogSource clientLogger;
private readonly ManualLogSource clientLogger = BepInEx.Logging.Logger.CreateLogSource("Fika.Client");
public bool ClientReady = false;

protected void Start()
{
clientLogger = new("Fika Client");

packetProcessor.SubscribeNetSerializable<PlayerStatePacket, NetPeer>(OnPlayerStatePacketReceived);
packetProcessor.SubscribeNetSerializable<GameTimerPacket, NetPeer>(OnGameTimerPacketReceived);
Expand Down
10 changes: 7 additions & 3 deletions Fika.Core/Networking/FikaPingingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Fika.Core.Networking
internal class FikaPingingClient(string serverId) : INetEventListener
{
public NetManager NetClient;
private readonly ManualLogSource _logger = new("Pinging Client");
private readonly ManualLogSource _logger = Logger.CreateLogSource("Fika.PingingClient");
private readonly string serverId = serverId;
private IPEndPoint remoteEndPoint;
public bool Received = false;
Expand Down Expand Up @@ -58,8 +58,7 @@ public bool PingEndPoint()
NetDataWriter writer = new();
writer.Put("fika.hello");

bool success = NetClient.SendUnconnectedMessage(writer, remoteEndPoint);
return success;
return NetClient.SendUnconnectedMessage(writer, remoteEndPoint);
}

public void OnConnectionRequest(ConnectionRequest request)
Expand All @@ -84,7 +83,12 @@ public void OnNetworkReceive(NetPeer peer, NetPacketReader reader, byte channelN

public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
{
if (Received)
{
return;
}
_logger.LogInfo("Received response from server, parsing...");

if (reader.TryGetString(out string result))
{
if (result == "fika.hello")
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Networking/FikaServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public NetManager NetServer
}
public DateTime timeSinceLastPeerDisconnected = DateTime.Now.AddDays(1);
public bool hasHadPeer = false;
private readonly ManualLogSource serverLogger = new("Fika Server");
private readonly ManualLogSource serverLogger = BepInEx.Logging.Logger.CreateLogSource("Fika.Server");
public bool ServerReady = false;
private int _currentNetId;

Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/UI/Custom/MatchMakerUIScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private IEnumerator JoinMatch(string profileId, string serverId, Button button)
success = pingingClient.Received;
}
yield return new WaitForFixedUpdate();
} while (attempts < 5 && !success);
} while (!success && attempts < 5);

if (!success)
{
Expand Down

0 comments on commit 5421dea

Please sign in to comment.