Builds log record (typically, but not necessarily a string) for an action. You can think of the LogRecordBuilder as a semantic StringBuilder. PostSharp emits code that invoke methods such as SetParameter<T>(int, string, ParameterKind, string, T) or SetReturnValue<T>(int, string, string, T, IFormatter<T>), and the responsibility of the LogRecordBuilder is to format a record and emit it to the back-end.
Namespace: PostSharp.Patterns.Diagnostics.RecordBuilders
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public abstract class LogRecordBuilder : ICustomLogRecordBuilder, IDisposableConstructors
| 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 |
| 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>(int, 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, bool) | Sets the method or activity execution time. |
| SetMethodGenericParameter<T>(int) | Not implemented. |
| SetParameter<T>(int, string, ParameterKind, string, T) | Sets the value of a given parameter and uses the default formatter. |
| SetParameter<T>(int, string, ParameterKind, string, T, IFormatter<T>) | Sets the value of a given parameter and specifies the Formatter<T>. |
| SetReturnValue<T>(int, 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>(int, 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 |
| SetThis<T>(T, IFormatter<T>) | Sets the |
| SetTypeGenericParameter<T>(int) | 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>(int, in CharSpan, T, in CustomLogParameterOptions) | Writes a custom parameter (passed as an CharSpan) and uses the default formatter. |
| WriteCustomParameter<T>(int, in CharSpan, T, in CustomLogParameterOptions, IFormatter<T>) | Writes a custom parameter (passed as an CharSpan) and uses a given formatter. |
| WriteCustomParameter<T>(int, ArraySegment<char>, T) | Writes a custom parameter (passed as an |
| WriteCustomParameter<T>(int, ArraySegment<char>, T, IFormatter<T>) | Writes a custom parameter (passed as an |
| WriteCustomString(in CharSpan) | Write a custom string passed as an CharSpan. |
| WriteCustomString(ArraySegment<char>) | Write a custom string passed as an |