-
Notifications
You must be signed in to change notification settings - Fork 1
/
RedirectLogs.cs
41 lines (35 loc) · 1.27 KB
/
RedirectLogs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using Vintagestory.API.Client;
using Vintagestory.API.Common;
using Vintagestory.API.Server;
namespace VSModLauncher
{
/// <summary>
/// Redirects all log entries into the visual studio output window. Only for your convenience during development and testing.
/// </summary>
public class RedirectLogs : ModSystem
{
public override bool ShouldLoad(EnumAppSide side)
{
return true;
}
public override void StartServerSide(ICoreServerAPI api)
{
api.Server.Logger.EntryAdded += OnServerLogEntry;
}
private void OnServerLogEntry(EnumLogType logType, string message, params object[] args)
{
if (logType == EnumLogType.VerboseDebug) return;
System.Diagnostics.Debug.WriteLine("[Server " + logType + "] " + message, args);
}
public override void StartClientSide(ICoreClientAPI api)
{
api.World.Logger.EntryAdded += OnClientLogEntry;
}
private void OnClientLogEntry(EnumLogType logType, string message, params object[] args)
{
if (logType == EnumLogType.VerboseDebug) return;
System.Diagnostics.Debug.WriteLine("[Client " + logType + "] " + message, args);
}
}
}