feat(logging): build-config debug logging + task traceability #8
14
src/ClaudeDo.Logging/BuildConfig.cs
Normal file
14
src/ClaudeDo.Logging/BuildConfig.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Logging;
|
||||||
|
|
||||||
|
/// <summary>Runtime build-configuration detection — the replacement for #if DEBUG.
|
||||||
|
/// Debug builds compile with the JIT optimizer disabled; Release builds enable it.</summary>
|
||||||
|
public static class BuildConfig
|
||||||
|
{
|
||||||
|
public static bool IsDebug { get; } =
|
||||||
|
Assembly.GetEntryAssembly()
|
||||||
|
?.GetCustomAttribute<DebuggableAttribute>()
|
||||||
|
?.IsJITOptimizerDisabled ?? false;
|
||||||
|
}
|
||||||
19
tests/ClaudeDo.Worker.Tests/Logging/BuildConfigTests.cs
Normal file
19
tests/ClaudeDo.Worker.Tests/Logging/BuildConfigTests.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using ClaudeDo.Logging;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Worker.Tests.Logging;
|
||||||
|
|
||||||
|
public sealed class BuildConfigTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void IsDebug_MatchesEntryAssemblyDebuggableAttribute()
|
||||||
|
{
|
||||||
|
var entry = Assembly.GetEntryAssembly();
|
||||||
|
var expected = entry?
|
||||||
|
.GetCustomAttribute<DebuggableAttribute>()
|
||||||
|
?.IsJITOptimizerDisabled ?? false;
|
||||||
|
|
||||||
|
Assert.Equal(expected, BuildConfig.IsDebug);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user