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

TextLogRecordBuilder Class

An implementation of LogRecordBuilder that builds text-based log records. This class is the base class for most back-ends.

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

Constructors

Name Description
TextLogRecordBuilder(TextLoggingBackend)

Initializes a new TextLogRecordBuilder.

Properties

Name Description
Backend

Gets the parent back-end.

BackendOptions

Shortcut for this.Backend.Options.

Exception

Gets the Exception for the current record, or null if no exception is associated to the current record.

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 prefix used for parameter names.

Profile

Gets the LoggingProfile for the current record.

PropertyPrefix

Gets prefix used for property names.

ReturnItemPrefix

Gets prefix used for return values.

SourceLineInfo

Gets the SourceLineInfo for the current record.

SourceType

Gets the source System.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>(Int32, CharSpan, T, in CustomLogParameterOptions, IFormatter<T>)

Method invoked by WriteCustomParameter<T>(Int32, ArraySegment<Char>, T, IFormatter<T>) when for parameter mode is Hidden. The default implementation does not do anything.

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 command 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 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(Int32)

Appends indentation for the given to StringBuilder.

AppendMemberName()

Appends name of the member for the current record (including the declaring type name, subject to the IncludeType property) to the current StringBuilder, as well as an opening parenthesis.

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, Int32)

Appends a parameter to the current StringBuilder, where the name is given as a System.String, and uses a specific formatter. Back-ends 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, Int32)

Appends a parameter of System.String type to the current StringBuilder. Back-ends 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, Int32)

Appends a parameter to the current StringBuilder, where the name is given as a ArraySegment<T>, and uses a specific formatter. Back-ends 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, Int32)

Appends a parameter to the current StringBuilder, where the name is given as a System.String, and uses a specific formatter. Back-ends 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 source (file, line) information to the current StringBuilder.

AppendSpaces(Int32)

Appends a given number of spaces to the current StringBuilder.

AppendSpecialChar(Char)

Appends a special System.Char (which may require escaping with specific back-ends) to the current StringBuilder.

AppendTrailingPeriod()

Appends a trailing period (.) to the current StringBuilder, respecting the AppendTrailingPeriod property.

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 (i.e. non-custom) record for a given context and method.

BeginWriteItem(CustomLogRecordItem, in CustomLogRecordTextOptions)

Begins to build a 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 a next record in the same thread.

EmitRecord()

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

EmitRecord(Boolean)

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 a 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 the 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.

RequireDelimiter()

Causes the next call to the 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, Boolean)

Sets the method or activity execution time.

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

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

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, IFormatter<T>)

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

ShouldLogExceptionDetails()

Determines whether exception details should be appended to the text of the current StringBuilder.

ToString()
Write(UnsafeString)

Writes the final message to the back-end.

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

WriteProperty(LoggingProperty, Object, Int32)

Appends the name and value of a property to the current StringBuilder.

WriteProperty<T>(String, T, Int32, in LoggingPropertyOptions)

Appends the name and value of a property to the current StringBuilder.