add dates to some logs

This commit is contained in:
in0finite 2019-07-09 02:10:18 +02:00
parent 25f9c8a2a7
commit d022f6bb41
3 changed files with 14 additions and 4 deletions

View file

@ -72,7 +72,7 @@ namespace SanAndreasUnity.Net
{
// log some info
if (NetStatus.IsServer && !this.isLocalPlayer)
Debug.LogFormat("Player (netId={0}, addr={1}) connected", this.netId, this.connectionToClient.address);
Debug.LogFormat("Player (netId={0}, addr={1}) connected, time: {2}", this.netId, this.connectionToClient.address, F.CurrentDateForLogging);
F.InvokeEventExceptionSafe(onStart, this);
}
@ -83,7 +83,7 @@ namespace SanAndreasUnity.Net
// log some info about this
if (NetStatus.IsServer && !this.isLocalPlayer)
Debug.LogFormat("Player (netId={0}, addr={1}) disconnected", this.netId, this.connectionToClient.address);
Debug.LogFormat("Player (netId={0}, addr={1}) disconnected, time: {2}", this.netId, this.connectionToClient.address, F.CurrentDateForLogging);
}
void OnOwnedGameObjectChanged(GameObject newGo)

View file

@ -107,6 +107,18 @@ namespace SanAndreasUnity.Utilities
new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
}
public static string CurrentDateForLogging
{
get
{
try {
return System.DateTime.Now.ToString("dd MMM HH:mm:ss");
} catch {
return "";
}
}
}
public static string Nl2Br(this string str)
{
return str.Replace(Environment.NewLine, "<br>");

View file

@ -14,8 +14,6 @@
- add ability for client to request: ;
- port the whole UI to multiplayer
- fix connection timeout bug
- add current date to logs