Class LoggedRenderer<T>
Decorates an IRenderer<T> so that all event messages are logged.
Every single event message causes two log messages: one is logged before
rendering, and other one is logged after rendering. If any exception is thrown
it is also logged with the log level
Implements
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public class LoggedRenderer<T> : object, IRenderer<T> where T : IAction, new()
Type Parameters
Name | Description |
---|---|
T | An IAction type. It should match to BlockChain<T>'s type parameter. |
Remarks
Since IActionRenderer<T> is a subtype of IRenderer<T>, LoggedRenderer(IRenderer<T>, ILogger, LogEventLevel) constructor can take an IActionRenderer<T> instance as well. However, even it takes an action renderer, action-level fine-grained events will not be logged. For action renderers, please use LoggedActionRenderer<T> instead.
Examples
IRenderer<ExampleAction> renderer = new SomeRenderer();
// Wraps the renderer with LoggedRenderer:
renderer = new LoggedRenderer<ExampleAction>(
renderer,
Log.Logger,
LogEventLevel.Information,
);
Constructors
| Improve this Doc View SourceLoggedRenderer(IRenderer<T>, ILogger, LogEventLevel)
Creates a new LoggedRenderer<T> instance which decorates the given
renderer
.
Declaration
public LoggedRenderer(IRenderer<T> renderer, ILogger logger, LogEventLevel level = null)
Parameters
Type | Name | Description |
---|---|---|
IRenderer<T> | renderer | The actual renderer to forward all event messages to and actually render things. |
ILogger | logger | The logger to write log messages to. Note that all log messages
this decorator writes become in the context of the |
LogEventLevel | level | The log event level. All log messages become this level. |
Properties
| Improve this Doc View SourceLevel
The log event level. All log messages become this level.
Declaration
public LogEventLevel Level { get; }
Property Value
Type | Description |
---|---|
LogEventLevel |
Logger
The logger to write log messages to. Note that all log messages this decorator writes
become in the context of the Renderer's type (with the context
property SourceContext
).
Declaration
protected ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
Renderer
The inner renderer to forward all event messages to and actually render things.
Declaration
public IRenderer<T> Renderer { get; }
Property Value
Type | Description |
---|---|
IRenderer<T> |
Methods
| Improve this Doc View SourceLogBlockRendering(String, Block<T>, Block<T>, System.Action<Block<T>, Block<T>>)
Declaration
protected void LogBlockRendering(string methodName, Block<T> oldTip, Block<T> newTip, System.Action<Block<T>, Block<T>> callback)
Parameters
Type | Name | Description |
---|---|---|
String | methodName | |
Block<T> | oldTip | |
Block<T> | newTip | |
System.Action<Block<T>, Block<T>> | callback |
RenderBlock(Block<T>, Block<T>)
Declaration
public void RenderBlock(Block<T> oldTip, Block<T> newTip)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | |
Block<T> | newTip |
RenderReorg(Block<T>, Block<T>, Block<T>)
Declaration
public void RenderReorg(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | |
Block<T> | newTip | |
Block<T> | branchpoint |
RenderReorgEnd(Block<T>, Block<T>, Block<T>)
Declaration
public void RenderReorgEnd(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | |
Block<T> | newTip | |
Block<T> | branchpoint |