Show / Hide Table of Contents

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 (regardless of Level configuration).

Inheritance
Object
LoggedRenderer<T>
LoggedActionRenderer<T>
Implements
IRenderer<T>
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public class LoggedRenderer<T> : 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 Source

LoggedRenderer(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 renderer's type (with the context property SourceContext).

LogEventLevel level

The log event level. All log messages become this level.

Properties

| Improve this Doc View Source

Level

The log event level. All log messages become this level.

Declaration
public LogEventLevel Level { get; }
Property Value
Type Description
LogEventLevel
| Improve this Doc View Source

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
| Improve this Doc View Source

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 Source

LogBlockRendering(String, Block<T>, Block<T>, Action<Block<T>, Block<T>>)

Declaration
protected void LogBlockRendering(string methodName, Block<T> oldTip, Block<T> newTip, Action<Block<T>, Block<T>> callback)
Parameters
Type Name Description
String methodName
Block<T> oldTip
Block<T> newTip
Action<Block<T>, Block<T>> callback
| Improve this Doc View Source

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).

| Improve this Doc View Source

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 oldTip and newTip.

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.

| Improve this Doc View Source

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 oldTip and newTip.

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.

Implements

IRenderer<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium