Class LogBatcher<TItem>
Batches multiple log items into a smaller (usually single) number of log messages. The primary purpose is to preclude log flooding with repetitive error messages. Items represent log context, such as Exceptions etc. This class is not thread safe, however item addition is thread safe which makes it very convenient for use in places that use Parallel loops and the like.
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Azos.Log
Assembly: Azos.dll
Syntax
public class LogBatcher<TItem> : DisposableObject, IDisposable
Type Parameters
| Name | Description |
|---|---|
| TItem |
Constructors
LogBatcher(ILog)
Declaration
protected LogBatcher(ILog log)
Parameters
| Type | Name | Description |
|---|---|---|
| ILog | log |
Fields
Log
A log that messages will be written into when this instance is Disposed
Declaration
public readonly ILog Log
Field Value
| Type | Description |
|---|---|
| ILog |
m_Data
Declaration
protected readonly Dictionary<Type, LogBatcher<TItem>.ItemBatch> m_Data
Field Value
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary<System.Type, LogBatcher.ItemBatch<>> |
Properties
Channel
Default log message channel
Declaration
public string Channel { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
From
Default log message from
Declaration
public string From { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
HasItems
Declaration
public bool HasItems { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Topic
Default log message topic
Declaration
public string Topic { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Type
Default log message type
Declaration
public MessageType Type { get; set; }
Property Value
| Type | Description |
|---|---|
| MessageType |
Methods
Add(TItem)
Add item to the logger batch
Declaration
public void Add(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item |
Destructor()
Declaration
protected override sealed void Destructor()
Overrides
MakeBatch(TItem)
Override to make a custom batch type
Declaration
protected virtual LogBatcher<TItem>.ItemBatch MakeBatch(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item |
Returns
| Type | Description |
|---|---|
| LogBatcher.ItemBatch<> |
MakeMessages()
Override to turn accumulated batch state into a series of log messages
Declaration
protected virtual IEnumerable<Message> MakeMessages()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<Message> |
Implements
System.IDisposable