An implementation of LogRecordBuilder that builds text-based log records. This class is the base class for most backends.
Inheritance
Namespace: PostSharp.Patterns.Diagnostics.RecordBuilders
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public abstract class TextLogRecordBuilder : LogRecordBuilder, ICustomLogRecordBuilder, IDisposableRemarks
In a custom backend, derive a class from TextLogRecordBuilder and return a new instance from CreateRecordBuilder(). This class already builds the text of the record. To keep the default formatting, implement only the Write(UnsafeString) method, which emits the final text to the target logging framework. Override other virtual methods to change the formatting or to emit structured records.
The backend creates one instance for each thread, so a derived class does not need to be thread-safe.
Constructors
| Name | Description |
|---|---|
| TextLogRecordBuilder(TextLoggingBackend) | Initializes a new instance of the TextLogRecordBuilder class. |
Properties
| Name | Description |
|---|---|
| Backend | Gets the parent backend. |
| BackendOptions | Gets the options of the parent backend. This property is a shortcut for |
| Exception | Gets the Exception for the current record, or |
| Level | Gets the LogLevel for the current record. |
| MemberName | Gets the name of the method, property or field for the current record. |
| Options | Gets the LoggingOptions for the current record. |
| ParameterPrefix | Gets the prefix used for parameter names. |
| Profile | Gets the LoggingProfile for the current record. |
| PropertyPrefix | Gets the prefix used for property names. |
| ReturnItemPrefix | Gets the prefix used for return values. |
| SourceLineInfo | Gets the SourceLineInfo for the current record. |
| SourceType | Gets the source Type of the current record. |
| StringBuilder | Gets the current UnsafeStringBuilder where everything is being appended. |
| TypeSource | Gets the LoggingTypeSource for the current record. |
Methods
| Name | Description |
|---|---|
| AddHiddenCustomParameter<T>(int, CharSpan, T, in CustomLogParameterOptions, IFormatter<T>) | Method invoked by WriteCustomParameter<T>(int, ArraySegment<char>, T, IFormatter<T>) when the parameter mode is Hidden. The default implementation does nothing. |
| AppendAsyncInfo() | Appends information about the async method to the current StringBuilder. |
| AppendClosingParenthesisConditional() | Appends a closing parenthesis to the current StringBuilder if required. |
| AppendComma() | Appends a comma and a space to the current StringBuilder, and resets the required punctuation set by RequireComma() or RequirePunctuation(char). |
| AppendCommaConditional() | Appends a comma to the current StringBuilder, unless this method is invoked for the first time for the current record. |
| AppendContextDescription() | Appends the context Description (or the TypeSource name, if the type of the context is not equal to the source type of the record) to the current StringBuilder. |
| AppendContextDescription(LoggingContext) | Appends the context Description to the current StringBuilder. |
| AppendDelimiter() | Appends a Delimiter to the current StringBuilder. |
| AppendDelimiterConditional() | Appends a Delimiter to the current StringBuilder if the RequireDelimiter() method has been called previously. |
| AppendEpilogue() | Appends the final part of the log message to StringBuilder. This includes state machine number and execution time where relevant, but does not include exception details. |
| AppendExceptionDetails() | Appends exception details to StringBuilder if IncludeExceptionDetails is set. |
| AppendExecutionTime() | Appends the execution time to the current StringBuilder. |
| AppendExecutionTimeThreshold() | Appends the execution time threshold to the current StringBuilder. |
| AppendIndentString(int) | Appends indentation for the given to StringBuilder. |
| AppendMemberName() | Appends the name of the member for the current record, followed by an opening parenthesis, to the current StringBuilder. The declaring type name is included according to the IncludeType property. |
| AppendOpeningParenthesis() | Appends an opening parenthesis to the current StringBuilder. |
| AppendProlog() | Appends the indent string, context description, and the record kind to the current StringBuilder. |
| AppendRecordKind() | Appends the LogRecordKind of the current record to the current StringBuilder. |
| AppendSemanticParameter(SemanticParameterKind, string, object, IFormatter, string, int) | Appends a parameter to the current StringBuilder. The name is given as a string, and a specific formatter formats the value. Backends that support semantic logging may store the parameter value semantically instead of appending it to the StringBuilder. This method overload is weakly typed. |
| AppendSemanticParameter(SemanticParameterKind, string, string, string, int) | Appends a parameter of string type to the current StringBuilder. Backends that support semantic logging may store the parameter value semantically instead of appending it to the StringBuilder. |
| AppendSemanticParameter<T>(SemanticParameterKind, ArraySegment<char>, T, IFormatter<T>, string, int) | Appends a parameter to the current StringBuilder. The name is given as an ArraySegment<T>, and a specific formatter formats the value. Backends that support semantic logging may store the parameter value semantically instead of appending it to the StringBuilder. |
| AppendSemanticParameter<T>(SemanticParameterKind, string, T, IFormatter<T>, string, int) | Appends a parameter to the current StringBuilder. The name is given as a string, and a specific formatter formats the value. Backends that support semantic logging may store the parameter value semantically instead of appending it to the StringBuilder. This method overload is strongly typed. |
| AppendSourceLineInfo() | Appends the source information (file and line) to the current StringBuilder. |
| AppendSpaces(int) | Appends a given number of spaces to the current StringBuilder. |
| AppendSpecialChar(char) | Appends a special char to the current StringBuilder. Some backends may require escaping this character. |
| AppendTrailingPeriod() | Appends a trailing period ( |
| AppendTypeName() | Appends the name of the TypeSource to the current StringBuilder. |
| 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 (non-custom) record for a given context and method. |
| BeginWriteItem(CustomLogRecordItem, in CustomLogRecordTextOptions) | Begins building the specified item. |
| 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 the next record in the same thread. |
| EmitRecord() | Emits the record. Invoked by the Complete() method. |
| EmitRecord(bool) | Emits the record and specifies whether exception details should be appended to the text. |
| EndContextDescription() | Ends building the context Description and starts building the action text. |
| EndContextDescriptionConditional() | Switches between building the context Description and the action text. If the EndContextDescriptionConditional() method has been previously invoked, subsequent calls are ignored. |
| EndWriteItem(CustomLogRecordItem) | Ends building the specified item. |
| GetContextDescription() | Gets the context Description or the TypeSource name, if the type of the context is not equal to the source type of the record. |
| GetContextDescriptionUnsafe() | Gets an UnsafeString representing the context Description or the TypeSource name, if the type of the context is not equal to the source type of the record. |
| GetContextForDescription() | Gets the LoggingContext that should be used when getting or appending the Description. |
| GetSourceName() | Gets the name of the TypeSource for the current record, respecting the IncludeNamespace property. |
| HasRecordKindName() | Determines whether AppendRecordKind() will append anything for the current record. |
| MustBuildContextDescription() | Determines whether the current Description should be appended to the current StringBuilder. |
| RequireComma() | Requires the next call to AppendCommaConditional() to append a comma even if it is the first call. |
| RequireDelimiter() | Causes the next call to AppendDelimiterConditional() to append a Delimiter to the current StringBuilder. |
| RequirePunctuation(char) | Requires the next call to AppendCommaConditional() to append a specific punctuation character. |
| 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. |
| 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, IFormatter<T>) | Sets a given return value and uses a given formatter. A method can have several return values in C# 7.0. |
| SetThis<T>(T, IFormatter<T>) | Sets the |
| ShouldLogExceptionDetails() | Determines whether exception details should be appended to the text of the current StringBuilder. |
| ToString() | |
| Write(UnsafeString) | Writes the final message to the backend. |
| WriteCustomParameter<T>(int, in CharSpan, T, in CustomLogParameterOptions, IFormatter<T>) | Writes a custom parameter (passed as a CharSpan) and uses a given formatter. |
| WriteCustomParameter<T>(int, ArraySegment<char>, T, IFormatter<T>) | Writes a custom parameter (passed as an |
| WriteCustomString(in CharSpan) | Writes a custom string that is passed as a CharSpan. |
| WriteCustomString(ArraySegment<char>) | Writes a custom string that is passed as an |
| WriteProperty(LoggingProperty, object, int) | Appends the name and value of a property to the current StringBuilder. |
| WriteProperty<T>(string, T, int, in LoggingPropertyOptions) | Appends the name and value of a property to the current StringBuilder. |