Interface IActivityMonitor
Defines the core Activity Monitor interface. Small is beautiful.
Namespace: CK.Core
Assembly: CK.ActivityMonitor.dll
Syntax
public interface IActivityMonitor
Remarks
This is not the same as a classical logging framework: the "activity" captures by an activity monitor is structured. It can be seen as a "Story Writer": its output can be displayed to an end user (even if some structured information can easily be injected). Furthermore, activities can be tracked (with the help of the developer of course) across threads, tasks or application domain.
Properties
| Improve this Doc View SourceActualFilter
Gets the actual filter level for logs: this combines the configured MinimalFilter and the minimal requirements of any IActivityMonitorBoundClient that specifies such a minimal filter level.
Declaration
LogFilter ActualFilter { get; }
Property Value
| Type | Description |
|---|---|
| LogFilter |
Remarks
This does NOT take into account the static (application-domain) DefaultFilter. This global default must be used if this ActualFilter is None for Line or Group: the ShouldLogLine(IActivityMonitor, LogLevel, String, Int32) extension method takes it into account.
AutoTags
Gets or sets the tags of this monitor: any subsequent logs will be tagged by these tags. The CK.Core.CKTrait must be registered in ActivityMonitor.Tags. Modifications to this property are scoped to the current Group since when a Group is closed, this property (and MinimalFilter) is automatically restored to its original value (captured when the Group was opened).
Declaration
CKTrait AutoTags { get; set; }
Property Value
| Type | Description |
|---|---|
| CK.Core.CKTrait |
LastLogTime
Gets the last CK.Core.DateTimeStamp for this monitor.
Declaration
DateTimeStamp LastLogTime { get; }
Property Value
| Type | Description |
|---|---|
| CK.Core.DateTimeStamp |
MinimalFilter
Gets or sets a filter for the log level. Modifications to this property are scoped to the current Group since when a Group is closed, this property (and AutoTags) is automatically restored to its original value (captured when the Group was opened). Defaults to Undefined.
Declaration
LogFilter MinimalFilter { get; set; }
Property Value
| Type | Description |
|---|---|
| LogFilter |
Output
Gets the IActivityMonitorOutput for this monitor.
Declaration
IActivityMonitorOutput Output { get; }
Property Value
| Type | Description |
|---|---|
| IActivityMonitorOutput |
Topic
Gets the current topic for this monitor. This can be any non null string (null topic is mapped to the empty string) that describes the current activity. It must be set with SetTopic(String, String, Int32) and unlike MinimalFilter and AutoTags, the topic is not reseted when groups are closed.
Declaration
string Topic { get; }
Property Value
| Type | Description |
|---|---|
| String |
Remarks
Clients are warned of the change thanks to OnTopicChanged(String, String, Int32) and an unfiltered Info log with the new topic prefixed with "Topic:" and tagged with MonitorTopicChanged is emitted.
Methods
| Improve this Doc View SourceCloseGroup(DateTimeStamp, Object)
Closes the current Group. Optional parameter is polymorphic. It can be a string, a ActivityLogGroupConclusion, a List<T> or an IEnumerable<T> of ActivityLogGroupConclusion, or any object with an overridden ToString() method. See remarks (especially for List<ActivityLogGroupConclusion>).
Declaration
bool CloseGroup(DateTimeStamp logTime, object userConclusion = null)
Parameters
| Type | Name | Description |
|---|---|---|
| CK.Core.DateTimeStamp | logTime | Log time of the closing of the group. You can use CK.Core.DateTimeStamp.UtcNow or NextLogTime(IActivityMonitor) extension method. |
| Object | userConclusion | Optional string, ActivityLogGroupConclusion object, enumerable of ActivityLogGroupConclusion or object to conclude the group. See remarks. |
Returns
| Type | Description |
|---|---|
| Boolean | True if a group has actually been closed, false if there is no more opened group. |
Remarks
An untyped object is used here to easily and efficiently accommodate both string and already existing ActivityLogGroupConclusion. When a List<ActivityLogGroupConclusion> is used, it will be directly used to collect conclusion objects (new conclusions will be added to it). This is an optimization.
SetTopic(String, String, Int32)
Sets the current topic for this monitor. This can be any non null string (null topic is mapped to the empty string) that describes the current activity.
Declaration
void SetTopic(string newTopic, string fileName = null, int lineNumber = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| String | newTopic | The new topic string to associate to this monitor. |
| String | fileName | The source code file name from which the topic is set. |
| Int32 | lineNumber | The line number in the source from which the topic is set. |
UnfilteredLog(ActivityMonitorLogData)
Logs a line regardless of ActualFilter level (except for Off).
Declaration
void UnfilteredLog(ActivityMonitorLogData data)
Parameters
| Type | Name | Description |
|---|---|---|
| ActivityMonitorLogData | data | Data that describes the log. Can not be null. |
UnfilteredOpenGroup(ActivityMonitorGroupData)
Opens a group regardless of ActualFilter level (except for Off). CloseGroup(DateTimeStamp, Object) must be called in order to close the group, and/or the returned object must be disposed (both safely can be called: the group is closed on the first action, the second one is ignored).
Declaration
IDisposableGroup UnfilteredOpenGroup(ActivityMonitorGroupData data)
Parameters
| Type | Name | Description |
|---|---|---|
| ActivityMonitorGroupData | data | Data that describes the log. Can not be null. |
Returns
| Type | Description |
|---|---|
| IDisposableGroup | A disposable object that can be used to set a function that provides a conclusion text and/or close the group. |
Remarks
Opening a group does not change the current MinimalFilter, except when opening a Fatal or Error group: in such case, the MinimalFilter is automatically sets to Trace to capture all potential information inside the error group.
Changes to the monitor's current Filter or AutoTags that occur inside a group are automatically restored to their original values when the group is closed. This behavior guaranties that a local modification (deep inside unknown called code) does not impact caller code: groups are a way to easily isolate such configuration changes.
Note that this automatic configuration restoration works even if the group has been filtered.