Skip to content

Commit ae54d57

Browse files
committed
Add log file for use by client mods
1 parent fd46fcf commit ae54d57

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

KSPBuildTools.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@
3838
<None Include="KSPCommon.props" Pack="True" PackagePath="build/KSPBuildTools.props" />
3939
<None Include="KSPCommon.targets" Pack="True" PackagePath="build/KSPBuildTools.targets" />
4040
<None Include="README.md" Pack="True" PackagePath="/"/>
41+
<None Include="include/*.cs" Pack="True" PackagePath="/build/include/"/>
4142
</ItemGroup>
4243

4344
<ItemGroup>
45+
<Compile Remove="**/*.cs" />
4446
<Compile Remove="$(MSBuildThisFileDirectory)tests/**" />
4547
<None Remove="$(MSBuildThisFileDirectory)tests/**" />
4648
<Compile Remove="$(MSBuildThisFileDirectory).github/**" />

KSPCommon.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,8 @@
129129
<Private>False</Private>
130130
</Reference>
131131
</ItemGroup>
132+
133+
<ItemGroup>
134+
<Compile Include = "$(MSBuildThisFileDirectory)/include/*.cs" Condition="exists('$(MSBuildThisFileDirectory)/include')"/>
135+
</ItemGroup>
132136
</Project>

include/Log.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using System.Runtime.CompilerServices;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using UnityEngine;
9+
10+
namespace KSPBuildTools
11+
{
12+
internal static class Log
13+
{
14+
internal static string Prefix = "[" + Assembly.GetExecutingAssembly().GetName().Name + "] ";
15+
16+
[System.Diagnostics.Conditional("DEBUG")]
17+
internal static void Debug(string message)
18+
{
19+
UnityEngine.Debug.Log(Prefix + message);
20+
}
21+
22+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
23+
internal static void Message(string message)
24+
{
25+
UnityEngine.Debug.Log(Prefix + message);
26+
}
27+
28+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
29+
internal static void Warning(string message)
30+
{
31+
UnityEngine.Debug.LogWarning(Prefix + message);
32+
}
33+
34+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
35+
internal static void Error(string message)
36+
{
37+
UnityEngine.Debug.LogError(Prefix + message);
38+
}
39+
40+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
41+
internal static void Exception(Exception ex)
42+
{
43+
UnityEngine.Debug.LogException(ex);
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)