Show / Hide Table of Contents

Class LoggedActionRenderer

Decorates an IActionRenderer so that all event messages are logged. In other words, this is an IActionRenderer version of LoggedRenderer.

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 Serilog.Events.LogEventLevel.Error (regardless of Level configuration).

Inheritance
Object
LoggedRenderer
LoggedActionRenderer
Implements
IActionRenderer
IRenderer
Inherited Members
LoggedRenderer.Renderer
LoggedRenderer.Level
LoggedRenderer.Logger
LoggedRenderer.RenderBlock(Block, Block)
LoggedRenderer.LogBlockRendering(String, Block, Block, Action<Block, Block>)
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 LoggedActionRenderer : LoggedRenderer, IActionRenderer, IRenderer
Examples
IActionRenderer actionRenderer = new SomeActionRenderer();
// Wraps the action renderer with LoggedActionRenderer:
actionRenderer = new LoggedActionRenderer(
    actionRenderer,
    Log.Logger,
    LogEventLevel.Information,
);

Constructors

| Improve this Doc View Source

LoggedActionRenderer(IActionRenderer, ILogger, LogEventLevel)

Creates a new LoggedActionRenderer instance which decorates the given action renderer.

Declaration
public LoggedActionRenderer(IActionRenderer renderer, ILogger logger, LogEventLevel level = LogEventLevel.Debug)
Parameters
Type Name Description
IActionRenderer renderer

The actual action renderer to forward all event messages to and actually render things.

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

Serilog.Events.LogEventLevel level

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

Properties

| Improve this Doc View Source

ActionRenderer

The inner action renderer to forward all event messages to and actually render things.

Declaration
public IActionRenderer ActionRenderer { get; }
Property Value
Type Description
IActionRenderer

Methods

| Improve this Doc View Source

RenderAction(IValue, IActionContext, IAccountStateDelta)

Does things that should be done right after an action is executed and applied to the blockchain.

Declaration
public void RenderAction(IValue action, IActionContext context, IAccountStateDelta nextStates)
Parameters
Type Name Description
Bencodex.Types.IValue action

An executed action.

IActionContext context

The equivalent context object to an object passed to the action's Execute(IActionContext) method. That means PreviousStates are the states right before this action executed. For the states after this action executed, use the nextStates argument instead.

IAccountStateDelta nextStates

The states right after this action executed, which means it is equivalent to the states action's Execute(IActionContext) method returned.

Remarks

It is guaranteed to be called only once for an action, and only after applied to the blockchain, unless an exception is thrown during executing the action (in that case RenderActionError(IValue, IActionContext, Exception) is called instead) or once the action has been unrendered.

Also note that this method is invoked after RenderBlock(Block, Block) method is called (where its second parameter newTip contains a transaction the action belongs to).

| Improve this Doc View Source

RenderActionError(IValue, IActionContext, Exception)

Does the similar things to RenderAction(IValue, IActionContext, IAccountStateDelta), except that this method is invoked when action has terminated with an exception.

Declaration
public void RenderActionError(IValue action, IActionContext context, Exception exception)
Parameters
Type Name Description
Bencodex.Types.IValue action

An action which threw an exception during execution.

IActionContext context

The equivalent context object to an object passed to the action's Execute(IActionContext) method. That means PreviousStates are the states right before this action executed.

Exception exception

The exception thrown during executing the action.

Remarks

Also note that this method is invoked after RenderBlock(Block, Block) method is called (where its second parameter newTip contains a transaction the action belongs to).

| Improve this Doc View Source

RenderBlockEnd(Block, Block)

Does things that should be done right all actions in a new Block are rendered.

Declaration
public void RenderBlockEnd(Block oldTip, Block newTip)
Parameters
Type Name Description
Block oldTip

The previous Tip.

Block newTip

The current Tip.

Remarks

It is guaranteed to be called only once for a block.

Implements

IActionRenderer
IRenderer
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium