Skip to content

Commit

Permalink
Add extra logging to log file cleanup
Browse files Browse the repository at this point in the history
Also revert runtime flag for a few tests (incorrecrly changed when runtime )

Work done for #196
  • Loading branch information
atruskie committed Mar 30, 2020
1 parent 3381ee9 commit 8abafea
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/Acoustics.Shared/Logging/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ public class Logging : IDisposable
{
public const string CleanLogger = "CleanLogger";
public const string LogFileOnly = "LogFileOnly";
private const string LogPrefix = "log_";

public static readonly Assembly RootNamespace = typeof(Logging).Assembly;
public static readonly string LogFolder = Path.Combine(AppConfigHelper.ExecutingAssemblyDirectory, "Logs");

private const string LogPrefix = "log_";

private readonly Logger rootLogger;

// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
Expand Down Expand Up @@ -227,7 +228,7 @@ public void Dispose()
/// Initializes the logging system.
/// </summary>
/// <param name="defaultLevel">The default level to set for the root logger.</param>
/// <param name="quietConsole">If True limits the level on the appenders to <see cref="Level.Error"/></param>
/// <param name="quietConsole">If True limits the level on the appenders to <see cref="Level.Error"/>.</param>
public void ModifyVerbosity(Level defaultLevel, bool quietConsole)
{
this.repository.Threshold = defaultLevel;
Expand Down Expand Up @@ -300,7 +301,7 @@ void CleanFiles()

// assuming a format of log_20180717T130822Z.1.txt
int prefixLength = LogPrefix.Length;
var datePart = name.Substring(prefixLength, name.IndexOf(".", StringComparison.Ordinal) - prefixLength);
var datePart = name[prefixLength..name.IndexOf(".", StringComparison.Ordinal)];
var success = DateTime.TryParseExact(
datePart,
"yyyyMMddTHHmmssZ",
Expand Down Expand Up @@ -350,7 +351,7 @@ void CleanFiles()
}
catch (Exception ex)
{
LoggedConsole.WriteFatalLine("Log cleaning failed, this is a bug, please report it.", ex);
Console.WriteLine($"Log cleaning failed, this is a bug, please report it. {ex.Message}, {ex}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Acoustics.Test/AnalysisPrograms/MainEntryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class MainEntryTests
[DataRow(WinX64)]
[DataRow(OsxX64)]
[DataRow(LinuxX64)]
[DataRow(LinuxMuslX64)]

//[DataRow(LinuxMuslX64)]
//[DataRow(LinuxArm)]
//[DataRow(LinuxArm64)]
//[DataRow(WinArm64)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ namespace Acoustics.Test.AnalysisPrograms.Production
{
using System;
using System.IO;
using System.IO.Abstractions;
using Acoustics.Shared.Contracts;
using Acoustics.Test.TestHelpers;
using global::AnalysisPrograms.Production;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestHelpers;
using Acoustics.Shared.Contracts;
using System.IO.Abstractions;

//using Zio.FileSystems.Community.SqliteFileSystem;

[TestClass]
Expand All @@ -26,7 +27,6 @@ public void TestFullFileSystem(string path)
Assert.IsInstanceOfType(fs, typeof(FileSystem));
}


[TestMethod]
[Ignore("Broken to resolve .NET Core dependencies. https://github.com/QutEcoacoustics/audio-analysis/issues/289")]
public void TestSqliteFileSystem()
Expand Down
4 changes: 2 additions & 2 deletions tests/Acoustics.Test/RuntimesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Acoustics.Test
[TestCategory("Runtime")]
public class RuntimesTests
{
[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[RuntimeIdentifierSpecificDataTestMethod(RidType.CompiledIfSelfContained)]
[DataRow(WinX64, "win-x64/native/e_sqlite3.dll")]
[DataRow(WinArm64, "win-arm64/native/e_sqlite3.dll")]
[DataRow(OsxX64, "osx-x64/native/libe_sqlite3.dylib")]
Expand All @@ -44,7 +44,7 @@ public void TestRequiredSqliteLibsCopiedToBuildDir(string rid, string expected)
#pragma warning restore IDE0035, CS0162
}

[RuntimeIdentifierSpecificDataTestMethod(RidType.Compiled)]
[RuntimeIdentifierSpecificDataTestMethod(RidType.CompiledIfSelfContained)]
[DataRow(WinX64, "win-x64/lib/netstandard2.0/Mono.Posix.NETStandard.dll")]
[DataRow(OsxX64, "osx-x64/lib/netstandard2.0/Mono.Posix.NETStandard.dll")]
[DataRow(LinuxX64, "linux-x64/lib/netstandard2.0/Mono.Posix.NETStandard.dll")]
Expand Down
2 changes: 1 addition & 1 deletion tests/Acoustics.Test/Shared/LoggingTests/LoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task TestLogFilesAreCleaned()
// its cleaning logic
do
{
_ = new Logging(false, Level.Info, quietConsole: false);
new Logging(false, Level.Info, quietConsole: false).Dispose();
delta--;
}
while (delta > 0);
Expand Down

0 comments on commit 8abafea

Please sign in to comment.