-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Causing failure if logging cannot succeed
- Loading branch information
1 parent
032f5ba
commit bd04859
Showing
6 changed files
with
71 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
source/Octopus.Tentacle.Tests.Integration/Support/SetupFixtures/TentacleNLogFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.IO; | ||
using System; | ||
using Serilog; | ||
|
||
namespace Octopus.Tentacle.Tests.Integration.Support.SetupFixtures | ||
{ | ||
public static class TentacleNLogFile | ||
{ | ||
public static void TryAdjustForRuntime(TentacleRuntime runtime, ILogger logger, Func<string, string> adjustLogContents) | ||
{ | ||
try | ||
{ | ||
var exePath = TentacleExeFinder.FindTentacleExe(runtime); | ||
var exeFileInfo = new FileInfo(exePath); | ||
var nlogFileInfo = new FileInfo(Path.Combine(exeFileInfo.DirectoryName!, "Tentacle.exe.nlog")); | ||
|
||
var content = File.ReadAllText(nlogFileInfo.FullName); | ||
content = adjustLogContents(content); | ||
File.WriteAllText(nlogFileInfo.FullName, content); | ||
} | ||
catch (Exception e) | ||
{ | ||
logger.Error(e, $"Unable to turn on Trace logging for {runtime}"); | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...s.Integration/Support/SetupFixtures/TurnOnExceptionThrowingForLogFileForLatestTentacle.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using Serilog; | ||
|
||
namespace Octopus.Tentacle.Tests.Integration.Support.SetupFixtures | ||
{ | ||
public class TurnOnExceptionThrowingForLogFileForLatestTentacle : ISetupFixture | ||
{ | ||
public void OneTimeSetUp(ILogger logger) | ||
{ | ||
// This will help us find errors that normally get swallowed, and become hard to find. | ||
TryTurnOnExceptionThrowingForTentacleRuntime(TentacleRuntime.DotNet6, logger); | ||
TryTurnOnExceptionThrowingForTentacleRuntime(TentacleRuntime.Framework48, logger); | ||
} | ||
|
||
static void TryTurnOnExceptionThrowingForTentacleRuntime(TentacleRuntime runtime, ILogger logger) | ||
{ | ||
TentacleNLogFile.TryAdjustForRuntime( | ||
runtime, | ||
logger, | ||
content => content.Replace("throwExceptions=\"false\"", "throwExceptions=\"true\"")); | ||
} | ||
|
||
public void OneTimeTearDown(ILogger logger) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters