Class XUnitLogger
xUnit will have tests run parallel, and due to this it won't capture trace output correctly. This is where their ITestOutputHelper comes around, but Dapplo.Log can only have one logger. This class solves the problem by registering the ITestOutputHelper in the CallContext. Every log statement will retrieve the ITestOutputHelper from the context and use it to log.
Inherited Members
Namespace:Dapplo.Log.XUnit
Assembly:Dapplo.Log.XUnit.dll
Syntax
public class XUnitLogger : AbstractLogger, ILogger, ILoggerConfiguration
Constructors
| Improve this Doc View SourceXUnitLogger(ITestOutputHelper)
Prevent the constructor from being use elsewhere, this also makes it impossible to use LogSettings.RegisterDefaultLogger
Declaration
public XUnitLogger(ITestOutputHelper testOutputHelper)
Parameters
Type | Name | Description |
---|---|---|
Xunit.Abstractions.ITestOutputHelper | testOutputHelper |
Properties
| Improve this Doc View SourceLogLevel
LogLevel, this can give a different result pro xUnit test... It will depend on the RegisterLogger value which was used in the current xUnit test
Declaration
public override LogLevels LogLevel { get; set; }
Property Value
Type | Description |
---|---|
LogLevels |
Overrides
Methods
| Improve this Doc View SourceIsLogLevelEnabled(LogLevels, LogSource)
If the level is enabled, this returns true The level depends on what the xUnit test used in the RegisterLogger
Declaration
public override bool IsLogLevelEnabled(LogLevels logLevel, LogSource logSource = null)
Parameters
Type | Name | Description |
---|---|---|
LogLevels | logLevel | LogLevels enum |
LogSource | logSource | optional LogSource |
Returns
Type | Description |
---|---|
System.Boolean | true if the level is enabled |
Overrides
| Improve this Doc View SourceWrite(LogInfo, String, Object[])
There is not Write for the ITestOutputHelper
Declaration
public override void Write(LogInfo logInfo, string messageTemplate, params object[] logParameters)
Parameters
Type | Name | Description |
---|---|---|
LogInfo | logInfo | |
System.String | messageTemplate | |
System.Object[] | logParameters |
Overrides
| Improve this Doc View SourceWriteLine(LogInfo, String, Object[])
Writes the output to the testOutputHelper
Declaration
public override void WriteLine(LogInfo logInfo, string messageTemplate, params object[] logParameters)
Parameters
Type | Name | Description |
---|---|---|
LogInfo | logInfo | LogInfo |
System.String | messageTemplate | string |
System.Object[] | logParameters | params object |