Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions Source/FluidWarpMod/FluidWarp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FluidWarpMod</RootNamespace>
<AssemblyName>FluidWarp</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -36,27 +36,21 @@
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\lib\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\lib\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="UnityEngine">
<HintPath>..\lib\UnityEngine.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\lib\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
46 changes: 15 additions & 31 deletions Source/FluidWarpMod/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,8 @@ namespace FluidWarpMod
{
static class Logger
{
internal sealed class FileLogHandler : ILogHandler, IDisposable
{
private FileStream fileStream;
private StreamWriter streamWriter;

public FileLogHandler(string LogFileName)
{
fileStream = new FileStream(LogFileName, FileMode.Create, FileAccess.ReadWrite);
streamWriter = new StreamWriter(fileStream);
}

public void Dispose()
{
fileStream.Dispose();
}

public void LogException(Exception exception, UnityEngine.Object context)
{
streamWriter.WriteLine("Exception: {0}", exception.Message);
streamWriter.WriteLine("Stacktrace: {0}", exception.StackTrace);
streamWriter.Flush();
}

public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args)
{
streamWriter.WriteLine(format, args);
streamWriter.Flush();
}
}
#if DEBUG
static UnityEngine.Logger u_logger = new UnityEngine.Logger(new FileLogHandler("Mods" + Path.DirectorySeparatorChar + "_Logs" + Path.DirectorySeparatorChar + "FluidWarpMod.txt"));
#if DEBUG
static UnityEngine.Logger u_logger;
#endif

public static void Log(string message)
Expand All @@ -56,6 +27,19 @@ public static void LogFormat(string template, params object[] args)
static Logger()
{
#if DEBUG
String logPath = "Mods" + Path.DirectorySeparatorChar + "_Logs" + Path.DirectorySeparatorChar + "FluidWarpMod.txt";
for (int i = 0; i < 3; i++)
{
try
{
u_logger = new UnityEngine.Logger(UnityEngine.Debug.unityLogger.logHandler);
}
catch (DirectoryNotFoundException ex)
{
Debug.LogError(ex.ToString() + $"\nUnity logger is not started since the direcrtory {logPath} doesn't exist");
Directory.CreateDirectory(Path.GetDirectoryName(logPath));
}
}
u_logger.logEnabled = true;
#endif
}
Expand Down