mirror of
https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities.git
synced 2026-09-09 01:45:58 +02:00
Fix exception when writing multiple logs at the same time
This commit is contained in:
@@ -6,6 +6,10 @@
|
|||||||
<RootNamespace>Stone_Red_C_Sharp_Utilities_Test</RootNamespace>
|
<RootNamespace>Stone_Red_C_Sharp_Utilities_Test</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Stone_Red-C-Sharp-Utilities\Stone_Red-C-Sharp-Utilities.csproj" />
|
<ProjectReference Include="..\Stone_Red-C-Sharp-Utilities\Stone_Red-C-Sharp-Utilities.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
namespace Stone_Red_C_Sharp_Utilities.Logging
|
using System;
|
||||||
|
|
||||||
|
namespace Stone_Red_C_Sharp_Utilities.Logging
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the target of the log message.
|
/// Specifies the target of the log message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Flags]
|
[Flags]
|
||||||
public enum LogTarget
|
public enum LogTarget
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -85,9 +85,13 @@ namespace Stone_Red_C_Sharp_Utilities.Logging
|
|||||||
public void ClearLogFile(LogSeverity logSeverity)
|
public void ClearLogFile(LogSeverity logSeverity)
|
||||||
{
|
{
|
||||||
OutputConfig outputConfig = GetOutputConfig(logSeverity);
|
OutputConfig outputConfig = GetOutputConfig(logSeverity);
|
||||||
if (File.Exists(outputConfig.FilePath))
|
|
||||||
|
lock (outputConfig)
|
||||||
{
|
{
|
||||||
File.WriteAllText(outputConfig.FilePath, string.Empty);
|
if (File.Exists(outputConfig.FilePath))
|
||||||
|
{
|
||||||
|
File.WriteAllText(outputConfig.FilePath, string.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,14 +115,17 @@ namespace Stone_Red_C_Sharp_Utilities.Logging
|
|||||||
Trace.WriteLine(debugOutput);
|
Trace.WriteLine(debugOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((outputConfig.LogTarget & LogTarget.File) == LogTarget.File)
|
lock (outputConfig)
|
||||||
{
|
{
|
||||||
if (!File.Exists(outputConfig.FilePath))
|
if ((outputConfig.LogTarget & LogTarget.File) == LogTarget.File)
|
||||||
{
|
{
|
||||||
File.Create(outputConfig.FilePath).Close();
|
if (!File.Exists(outputConfig.FilePath))
|
||||||
}
|
{
|
||||||
|
File.Create(outputConfig.FilePath).Close();
|
||||||
|
}
|
||||||
|
|
||||||
File.AppendAllLines(outputConfig.FilePath, new[] { fileOutput });
|
File.AppendAllLines(outputConfig.FilePath, new[] { fileOutput });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<AssemblyVersion>1.0.3.1</AssemblyVersion>
|
<AssemblyVersion>1.0.3.2</AssemblyVersion>
|
||||||
<FileVersion>1.0.3.1</FileVersion>
|
<FileVersion>1.0.3.2</FileVersion>
|
||||||
<Version>1.0.3.1</Version>
|
<Version>1.0.3.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
Reference in New Issue
Block a user