Class Sink
Represents logging message destination - an abstract entity that messages are written to by LogService.
Destinations must be efficient as they block logger thread. They provide failover mechanism when
processing can not be completed. Once failed, the processing can try to be resumed after configurable interval.
Destinations also provide optional SLA on the time it takes to perform actual message write - once exceeded destination is considered to have failed.
Basic efficient filtering is provided for times, dates and levels. Complex C# expression-based filtering is also supported
Inheritance
System.Object
Sink
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)
Assembly: Azos.dll
Syntax
public abstract class Sink : DaemonWithInstrumentation<ISinkOwner>, IDisposable, IDaemon, IDaemonView, IApplicationComponent, ILocalizedTimeProvider, IInstrumentable, IExternallyParameterized, IConfigurable, INamed, IOrdered
Constructors
Sink(ISinkOwner)
Declaration
protected Sink(ISinkOwner owner)
Parameters
Sink(ISinkOwner, String, Int32)
Declaration
protected Sink(ISinkOwner owner, string name, int order)
Parameters
Type |
Name |
Description |
ISinkOwner |
owner |
|
System.String |
name |
|
System.Int32 |
order |
|
Fields
CONFIG_DAYS_OF_WEEK_ATTR
Declaration
public const string CONFIG_DAYS_OF_WEEK_ATTR = "days-of-week"
Field Value
Type |
Description |
System.String |
|
CONFIG_END_DATE_ATTR
Declaration
public const string CONFIG_END_DATE_ATTR = "end-date"
Field Value
Type |
Description |
System.String |
|
CONFIG_END_TIME_ATTR
Declaration
public const string CONFIG_END_TIME_ATTR = "end-time"
Field Value
Type |
Description |
System.String |
|
CONFIG_FAILOVER_ATTR
Declaration
public const string CONFIG_FAILOVER_ATTR = "failover"
Field Value
Type |
Description |
System.String |
|
CONFIG_FILTER_ATTR
Declaration
public const string CONFIG_FILTER_ATTR = "filter"
Field Value
Type |
Description |
System.String |
|
CONFIG_GENERATE_FAILOVER_MSG_ATTR
Declaration
public const string CONFIG_GENERATE_FAILOVER_MSG_ATTR = "generate-failover-msg"
Field Value
Type |
Description |
System.String |
|
CONFIG_LEVELS_ATTR
Declaration
public const string CONFIG_LEVELS_ATTR = "levels"
Field Value
Type |
Description |
System.String |
|
CONFIG_MAX_LEVEL_ATTR
Declaration
public const string CONFIG_MAX_LEVEL_ATTR = "max-level"
Field Value
Type |
Description |
System.String |
|
CONFIG_MAX_PROCESSING_TIME_MS_ATTR
Declaration
public const string CONFIG_MAX_PROCESSING_TIME_MS_ATTR = "max-processing-time-ms"
Field Value
Type |
Description |
System.String |
|
CONFIG_MAX_PROCESSING_TIME_MS_MIN_VALUE
Declaration
public const int CONFIG_MAX_PROCESSING_TIME_MS_MIN_VALUE = 25
Field Value
Type |
Description |
System.Int32 |
|
CONFIG_MIN_LEVEL_ATTR
Declaration
public const string CONFIG_MIN_LEVEL_ATTR = "min-level"
Field Value
Type |
Description |
System.String |
|
CONFIG_ONLY_FAILURES_ATTR
Declaration
public const string CONFIG_ONLY_FAILURES_ATTR = "only-failures"
Field Value
Type |
Description |
System.String |
|
CONFIG_RESTART_PROCESSING_AFTER_MS_ATTR
Declaration
public const string CONFIG_RESTART_PROCESSING_AFTER_MS_ATTR = "restart-processing-after-ms"
Field Value
Type |
Description |
System.String |
|
CONFIG_RESTART_PROCESSING_AFTER_MS_DEFAULT
Declaration
public const int CONFIG_RESTART_PROCESSING_AFTER_MS_DEFAULT = 60000
Field Value
Type |
Description |
System.Int32 |
|
CONFIG_START_DATE_ATTR
Declaration
public const string CONFIG_START_DATE_ATTR = "start-date"
Field Value
Type |
Description |
System.String |
|
CONFIG_START_TIME_ATTR
Declaration
public const string CONFIG_START_TIME_ATTR = "start-time"
Field Value
Type |
Description |
System.String |
|
CONFIG_TEST_ON_START_ATTR
Declaration
public const string CONFIG_TEST_ON_START_ATTR = "test-on-start"
Field Value
Type |
Description |
System.String |
|
m_Order
Declaration
[Config]
protected int m_Order
Field Value
Type |
Description |
System.Int32 |
|
PROCESSING_TIME_EMA_FILTER
Defines how much smoothing the processing time filter does - the lower the number the more smoothing is done.
Smoothing makes MaxProcessingTimeMs detection insensitive to some seldom delays that may happen every now and then
while destination performs actual write into its sink
Declaration
public const float PROCESSING_TIME_EMA_FILTER = 0.0007F
Field Value
Type |
Description |
System.Single |
|
Properties
AverageProcessingTimeMs
Returns average time it takes destination implementation to write the log message to actual sink.
This property is only computed when MaxProcessingTimeMs limit is imposed, otherwise it returns 0f
Declaration
public float AverageProcessingTimeMs { get; }
Property Value
Type |
Description |
System.Single |
|
Channel
Declaration
[Config]
[ExternalParameter(new string[]{"log"})]
public string Channel { get; set; }
Property Value
Type |
Description |
System.String |
|
ComponentLogTopic
Declaration
public override string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
DaysOfWeek
Imposes a filter on days when this destination handles messages
Declaration
[Config("$days-of-week")]
[ExternalParameter(new string[]{"log"})]
public DaysOfWeek? DaysOfWeek { get; set; }
Property Value
EndDate
Imposes a filter that specifies the ending date and time
before which this destination will be processing log messages
Declaration
[Config("$end-date")]
[ExternalParameter(new string[]{"log"})]
public DateTime? EndDate { get; set; }
Property Value
Type |
Description |
System.Nullable<System.DateTime> |
|
EndTime
Imposes a filter that specifies the ending time of the day
before which this destination will be processing log messages
Declaration
[Config("$end-time")]
[ExternalParameter(new string[]{"log"})]
public TimeSpan? EndTime { get; set; }
Property Value
Type |
Description |
System.Nullable<System.TimeSpan> |
|
Failover
Sets destination name used for failover of this one
Declaration
[Config("$failover")]
[ExternalParameter(new string[]{"log"})]
public string Failover { get; set; }
Property Value
Type |
Description |
System.String |
|
Filter
Gets/sets filter expression for this destination.
Filter expressions get dynamically compiled into filter assembly,
consequently it is not a good practice to create too many different filters.
Filters are heavyweight, and it is advisable to use them ONLY WHEN regular destination filtering (using Min/Max levels, dates and times) can not be used
to achieve the desired result
Declaration
public MessageFilterExpression Filter { get; set; }
Property Value
FilterMethod
References message filtering method or null
Declaration
public MessageFilterHandler FilterMethod { get; set; }
Property Value
GenerateFailoverMessages
Determines whether additional co-related error message should be generated when this destination fails or when it is
used as failover by some other destination. When this property is true an additional error message gets written into failover destination that
describes what message caused failure (error is co-related to original) at what destination. False by default.
Declaration
[Config("$generate-failover-msg")]
[ExternalParameter(new string[]{"log"})]
public bool GenerateFailoverMessages { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
InstrumentationEnabled
Implements IInstrumentable
Declaration
[Config]
[ExternalParameter(new string[]{"log", "instrumentation"})]
public override bool InstrumentationEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Overrides
Azos.Apps.DaemonWithInstrumentation<Azos.Log.Sinks.ISinkOwner>.InstrumentationEnabled
LastError
Returns last error that this destination has encountered
Declaration
public Exception LastError { get; }
Property Value
Type |
Description |
System.Exception |
|
Levels
Declaration
public Sink.LevelsList Levels { get; set; }
Property Value
MaxLevel
Imposes a maximum log level constraint
Declaration
[Config("$max-level")]
[ExternalParameter(new string[]{"log"})]
public MessageType? MaxLevel { get; set; }
Property Value
MaxProcessingTimeMs
Imposes a time limit on internal message processing (writing into actual sink) by this destination.
If this limit is exceeded, this destination fails and processing is re-tried to be resumed after RestartProcessingAfterMs interval.
The minimum value for this property is 25 ms as lower values compromise timer accuracy
Declaration
[Config("$max-processing-time-ms")]
[ExternalParameter(new string[]{"log"})]
public int? MaxProcessingTimeMs { get; set; }
Property Value
Type |
Description |
System.Nullable<System.Int32> |
|
MinLevel
Imposes a minimum log level constraint
Declaration
[Config("$min-level")]
[ExternalParameter(new string[]{"log"})]
public MessageType? MinLevel { get; set; }
Property Value
OnlyFailures
Indicates whether this destination should only process failures - messages that crashed other destinations.
When set to true regular messages (dispatched by Send(msg)) are ignored
Declaration
[Config("$only-failures")]
[ExternalParameter(new string[]{"log"})]
public bool OnlyFailures { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Order
Provides log-wide sink processing order
Declaration
public int Order { get; }
Property Value
Type |
Description |
System.Int32 |
|
RestartProcessingAfterMs
Specifies how much time must pass before processing will be tried to resume after failure.
The default value is 60000 ms
Declaration
[Config("$restart-processing-after-ms")]
[ExternalParameter(new string[]{"log"})]
public int RestartProcessingAfterMs { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
StartDate
Imposes a filter that specifies the starting date and time
after which this destination will start processing log messages
Declaration
[Config("$start-date")]
[ExternalParameter(new string[]{"log"})]
public DateTime? StartDate { get; set; }
Property Value
Type |
Description |
System.Nullable<System.DateTime> |
|
StartTime
Imposes a filter that specifies the starting time of the day
after which this destination will start processing log messages
Declaration
[Config("$start-time")]
[ExternalParameter(new string[]{"log"})]
public TimeSpan? StartTime { get; set; }
Property Value
Type |
Description |
System.Nullable<System.TimeSpan> |
|
TestOnStart
Indicates whether this destination should try to test the underlying sink on startup.
For example DB-based destinations will try to connect to server upon log service launch when this property is true
Declaration
[Config("$test-on-start")]
public bool TestOnStart { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
Destructor()
Declaration
protected override void Destructor()
Overrides
Override to perform derivative-specific configuration
Declaration
protected override void DoConfigure(IConfigSectionNode node)
Parameters
Overrides
DoPulse()
Provides periodic notification of destinations from central Log thread even if there are no messages to write.
Override to commit internal batching buffers provided by particular destinations
Declaration
protected virtual void DoPulse()
DoSend(Message)
Performs physical send, i.e. storage in file for FileDestinations
Declaration
protected abstract void DoSend(Message entry)
Parameters
Type |
Name |
Description |
Message |
entry |
|
ParseLevels(String)
Parses levels into a tuple list of level ranges
Declaration
public static Sink.LevelsList ParseLevels(string levels)
Parameters
Type |
Name |
Description |
System.String |
levels |
String representation of levels using ',' or ';' or '|'
as range group delimiters, and '-' as range indicators. If first/second bound of the range
is empty, the min/max value of that bound is assumed.
Examples: "Debug-DebugZ | Error", "-DebugZ | Info | Warning", "Info-", "DebugB-DebugC, Error"
|
Returns
Pulse()
Provides periodic notification of destinations from central Log thread even if there are no messages to write.
Override DoPulse to commit internal batching buffers provided by particular destinations
Declaration
Send(Message)
Sends the message into destination doing filter checks first.
Declaration
public void Send(Message msg)
Parameters
SetError(Exception, Message)
Notifies log service of exception that surfaced during processing of a particular message
Declaration
protected void SetError(Exception error, Message msg)
Parameters
Type |
Name |
Description |
System.Exception |
error |
|
Message |
msg |
|
Implements
System.IDisposable
Extension Methods