/// <summary> /// Initializes a new instance of the <see cref="CloudWatchLogSink"/> class. /// </summary> /// <param name="cloudWatchClient">The cloud watch client.</param> /// <param name="options">The options.</param> public CloudWatchLogSink(IAmazonCloudWatchLogs cloudWatchClient, ICloudWatchSinkOptions options) : base(options.BatchSizeLimit, options.Period, options.QueueSizeLimit) { if (string.IsNullOrEmpty(options?.LogGroupName)) { throw new ArgumentException($"{nameof(ICloudWatchSinkOptions)}.{nameof(options.LogGroupName)} must be specified."); } if (options.BatchSizeLimit < 1) { throw new ArgumentException($"{nameof(ICloudWatchSinkOptions)}.{nameof(options.BatchSizeLimit)} must be a value greater than 0."); } this.cloudWatchClient = cloudWatchClient; this.options = options; if (options.TextFormatter == null) { throw new System.ArgumentException($"{nameof(options.TextFormatter)} is required"); } textFormatter = options.TextFormatter; }
/// <summary> /// Activates logging to AWS CloudWatch /// </summary> /// <param name="loggerConfiguration">The LoggerSinkConfiguration to register this sink with.</param> /// <param name="options">Options to be used for the CloudWatch sink. <see cref="ICloudWatchSinkOptions"/> and <see cref="CloudWatchSinkOptions"/> for details.</param> /// <param name="cloudWatchClient">An AWS CloudWatch client which includes access to AWS and AWS specific settings like the AWS region.</param> /// <returns></returns> public static LoggerConfiguration AmazonCloudWatch(this LoggerSinkConfiguration loggerConfiguration, ICloudWatchSinkOptions options, IAmazonCloudWatchLogs cloudWatchClient) { // validating input parameters if (loggerConfiguration == null) { throw new ArgumentNullException(nameof(loggerConfiguration)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (cloudWatchClient == null) { throw new ArgumentNullException(nameof(cloudWatchClient)); } // create the sink var sink = new CloudWatchLogSink(cloudWatchClient, options); // register the sink return(loggerConfiguration.Sink(sink, options.MinimumLogEventLevel)); }
public CloudWatchLogSinkWithLogging(IAmazonCloudWatchLogs cloudWatchClient, ICloudWatchSinkOptions options) : base(cloudWatchClient, options) { }