PostSharpAPI ReferencePost­Sharp.​Patterns.​Diagnostics.​Record­BuildersLog­Record­Builder
Open sandboxFocus

LogRecordBuilder Class

Builds log record (typically, but not necessarily a string) for an action. You can think of the LogRecordBuilder as a semantic System.Text.StringBuilder. PostSharp emits code that invoke methods such as SetParameter<T>(Int32, String, ParameterKind, String, T) or SetReturnValue<T>(Int32, String, String, T, IFormatter<T>), and the responsibility of the LogRecordBuilder is to format a record and emit it to the back-end.

Inheritance
System.Object
LogRecordBuilder
Namespace: PostSharp.Patterns.Diagnostics.RecordBuilders
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public abstract class LogRecordBuilder : Object, ICustomLogRecordBuilder

Constructors

Name Description
LogRecordBuilder()

Properties

Name Description
Context

Gets the LoggingContext to which the record belongs.

CustomRecordAttributes

Describes how the LogRecordBuilder will be used, when it is being used to build a custom message or a custom activity.

IsDisposed

Determines whether the current instance has been disposed.

RecordKind

Gets the kind of the current record (e.g. MethodEntry or MethodException).

SyntheticId

Gets a cross-process globally unique identifier for the current LoggingContext. This value is created according to value of the LoggingBackend.Options.SyntheticIdFormatter property.

ThreadContext

Gets the ThreadLoggingContext to which the current LogRecordBuilder belongs.

Methods

Name Description
BeginCustomRecord(LoggingContext, ref CustomLogRecordInfo)

Initializes the current LogRecordBuilder to emit a custom record.

BeginRecord(LoggingContext, ref LogRecordInfo, ref LogMemberInfo)

Initializes the current LogRecordBuilder to emit a standard (i.e. non-custom) record for a given context and method.

BeginWriteItem(CustomLogRecordItem, in CustomLogRecordTextOptions)

Begins to build a specified item.

Complete()

Emits the record and resets the current LogRecordBuilder. This method invoked after all SetThis<T>(T), SetParameter<T>(Int32, String, ParameterKind, String, T) and similar methods have been called.

Dispose()

Finishes the logging of the current record. Calling this method does not actually make the current LogRecordBuilder unusable, but it makes it usable for a next record in the same thread.

EmitRecord()

Emits the record. Invoked by the Complete() method.

EndWriteItem(CustomLogRecordItem)

Ends building a specified item.

ForEachProperty(LoggingPropertyVisitor<Object>)

Invokes a delegate for each property defined in the current log record.

ForEachProperty<T>(LoggingPropertyVisitor<T>, ref T)

Invokes a delegate for each property defined in the current log record.

GetOutputMultiplexEventData()

Returns a list of properties that will be passed to the next backend in order if a multiplexer is used. See Remarks.

Reset()

Resets all fields and properties of the current LogRecordBuilder to their initial value. Invoked by the Complete() method.

SetException(Exception)

Sets the exception for the method or activity.

SetExecutionTime(Double, Boolean)

Sets the method or activity execution time.

SetMethodGenericParameter<T>(Int32)

Not implemented.

SetParameter<T>(Int32, String, ParameterKind, String, T)

Sets the value of a given parameter and uses the default formatter.

SetParameter<T>(Int32, String, ParameterKind, String, T, IFormatter<T>)

Sets the value of a given parameter and specifies the Formatter<T>.

SetRefStructParameter(Int32, String, ParameterKind, String, Type, String)
SetReturnValue<T>(Int32, String, String, T)

Sets a given return value (there can be several return values in C# 7.0) and uses the default formatter.

SetReturnValue<T>(Int32, String, String, T, IFormatter<T>)

Sets a given return value (there can be several return values in C# 7.0) and uses a given formatter.

SetThis<T>(T)

Sets the this (instance) value and uses the default formatter. This method is only invoked if the IncludeThisValue property is true.

SetThis<T>(T, IFormatter<T>)

Sets the this (instance) value and uses a given formatter.

SetTypeGenericParameter<T>(Int32)

Not implemented.

VisitProperties(Action<String, Object>, in LoggingPropertyVisitorOptions)

Invokes a delegate each property on the current log record. This offers a simple way to visit properties, but it has a performance overhead compared to VisitProperties<TState>(ILoggingPropertyVisitor<TState>, ref TState, in LoggingPropertyVisitorOptions) because it is weakly typed and cause the allocation of a closure class to build the action. It also does not expose the LoggingPropertyOptions.

VisitProperties<TState>(ILoggingPropertyVisitor<TState>, ref TState, in LoggingPropertyVisitorOptions)

Invokes the Visit<TValue>(String, TValue, in LoggingPropertyOptions, ref TState) method of an interface implementation for each property on the current record, but not in the context stack.

WriteCustomParameter<T>(Int32, in CharSpan, T, in CustomLogParameterOptions)

Writes a custom parameter (passed as an CharSpan) and uses the default formatter.

WriteCustomParameter<T>(Int32, in CharSpan, T, in CustomLogParameterOptions, IFormatter<T>)

Writes a custom parameter (passed as an CharSpan) and uses a given formatter.

WriteCustomParameter<T>(Int32, ArraySegment<Char>, T)

Writes a custom parameter (passed as an ArraySegment<char>) and uses the default formatter.

WriteCustomParameter<T>(Int32, ArraySegment<Char>, T, IFormatter<T>)

Writes a custom parameter (passed as an ArraySegment<char>) and uses a given formatter.

WriteCustomString(in CharSpan)

Write a custom string passed as an CharSpan.

WriteCustomString(ArraySegment<Char>)

Write a custom string passed as an ArraySegment<char>.

Explicit Interface Implementations

Name Description
ICustomLogRecordBuilder.WriteCustomParameter<T>(Int32, in CharSpan, T, in CustomLogParameterOptions)