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>)
Does things that should be done right after a new Block<T> is appended to a BlockChain<T> (so that its Tip has changed).
Declaration
public void RenderBlock(Block<T> oldTip, Block<T> newTip)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The previous Tip. |
Block<T> | newTip | The current Tip. |
Remarks
It is guaranteed to be called only once for a block, and only after applied to the blockchain, unless it has been stale due to reorg (for that case, RenderReorg(Block<T>, Block<T>, Block<T>) is called in advance).
RenderReorg(Block<T>, Block<T>, Block<T>)
Does things that should be done right before reorg happens to a BlockChain<T>.
Declaration
public void RenderReorg(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The Tip right before reorg. |
Block<T> | newTip | The Tip after reorg. |
Block<T> | branchpoint | The highest common Block<T> between
|
Remarks
For every call to this method, calls to
RenderBlock(Block<T>, Block<T>) and
RenderReorgEnd(Block<T>, Block<T>, Block<T>) methods with the same
newTip
is made too. Note that this method is guaranteed to be called
before RenderBlock(Block<T>, Block<T>) method for the same
newTip
.
RenderReorgEnd(Block<T>, Block<T>, Block<T>)
Does things that should be done right before reorg happens to a BlockChain<T>.
Declaration
public void RenderReorgEnd(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The Tip right before reorg. |
Block<T> | newTip | The Tip after reorg. |
Block<T> | branchpoint | The highest common Block<T> between
|
Remarks
For every call to this method, calls to
RenderBlock(Block<T>, Block<T>) and
RenderReorgEnd(Block<T>, Block<T>, Block<T>) methods with the same
newTip
is made too. Note that this method is guaranteed to be called
before RenderBlock(Block<T>, Block<T>) method for the same
newTip
.