feat(logging): shared LoggingSetup with build-config sink branching
This commit is contained in:
30
tests/ClaudeDo.Worker.Tests/Logging/LoggingSetupTests.cs
Normal file
30
tests/ClaudeDo.Worker.Tests/Logging/LoggingSetupTests.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using ClaudeDo.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace ClaudeDo.Worker.Tests.Logging;
|
||||
|
||||
public sealed class LoggingSetupTests
|
||||
{
|
||||
[Fact]
|
||||
public void Configure_WritesSharedLogFile()
|
||||
{
|
||||
var logRoot = Path.Combine(Path.GetTempPath(), "claudedo-logtest-" + Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(logRoot);
|
||||
try
|
||||
{
|
||||
var logger = LoggingSetup.Configure(new LoggerConfiguration(), "test", logRoot).CreateLogger();
|
||||
logger.Warning("marker-{Marker}", "xyz");
|
||||
logger.Dispose(); // flush + release the file handle
|
||||
|
||||
var files = Directory.GetFiles(logRoot, "claudedo-*.log");
|
||||
var file = Assert.Single(files);
|
||||
var contents = File.ReadAllText(file);
|
||||
Assert.Contains("marker-", contents);
|
||||
Assert.Contains("test/", contents); // {Process} tag in the template
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { Directory.Delete(logRoot, recursive: true); } catch { /* best effort */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user