Allows enabling or disabling logging for a specific type, and exposes some information about the verbosity for this type. Note that a type here does not need to map to a .NET type. It can be an arbitrary dot-separated string.
Inheritance
Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public abstract class LoggingTypeSource : LoggingNamespaceSource, IContextLocalLogger, ILoggerExceptionHandlerRemarks
A LoggingTypeSource is identified by a role (see LoggingRoles) and a type name. It corresponds to the logger, category or source concept of the target logging framework. A log record is emitted only when logging is enabled both in PostSharp, through the LoggingVerbosityConfiguration, and in the target logging framework, as reported by IsBackendEnabled(LogLevel).
A custom backend derives a class from LoggingTypeSource, typically with a field that holds the logger of the target framework, and returns it from CreateTypeSource(LoggingNamespaceSource, Type). Because instances are shared by all threads, the derived class must be immutable or thread-safe.
Constructors
| Name | Description |
|---|---|
| LoggingTypeSource(LoggingNamespaceSource, string, Type) | Initializes a new instance of the LoggingTypeSource class. |
| LoggingTypeSource(LoggingNamespaceSource, Type) | Initializes a new instance of the LoggingTypeSource class. |
Properties
| Name | Description |
|---|---|
| GenericParameterCount | Gets the number of generic parameters in the type. |
| Options | Gets the LoggingRoleConfiguration for the current role. This property is a shortcut to |
| SourceType | Gets the type represented by the current LoggingTypeSource. This property may be |
Methods
| Name | Description |
|---|---|
| Clone(string) | Returns a deep clone of the current object. |
| IsBackendEnabled(LogLevel) | Checks whether logging is enabled in the backend for the given level. |
| IsEnabled(LogLevel) | Determines whether logging is enabled for the given LogLevel. |
| Refresh() | Refreshes the logging level from the backend for the current node and all child nodes. The backend-defined logging level is cached for performance reasons. |