public LogEntriesSinkBuilder(ISinkBuilderContext sinkBuilderContext,
                              IConfigurationSection config)
 {
     _sinkBuilderContext = sinkBuilderContext ??
                           throw new ArgumentNullException(nameof(sinkBuilderContext));
     _config = config ?? throw new ArgumentNullException(nameof(config));
 }
Exemple #2
0
        public static ISinkBuilderContext UseLoggly(this ISinkBuilderContext sinkBuilderContext,
                                                    IConfigurationSection config)
        {
            var builder = new LogglySinkBuilder(sinkBuilderContext, config);

            return(builder.BuildAndCloneContext(sinkBuilderContext));
        }
        public static ISinkBuilderContext UseAzureLogAnalytics(this ISinkBuilderContext sinkBuilderContext, IConfiguration configuration, Action <AzureLogAnalyticsOptions> configure = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var options = new AzureLogAnalyticsOptions();

            configuration.GetSection(nameof(AzureLogAnalyticsOptions)).Bind(options);
            configure?.Invoke(options);

            if (string.IsNullOrWhiteSpace(options.WorkspaceId))
            {
                throw new ArgumentException($"{nameof(options.WorkspaceId)} is missing in AzureLogAnalyticsOptions");
            }

            if (string.IsNullOrWhiteSpace(options.AuthenticationId))
            {
                throw new ArgumentException($"{nameof(options.AuthenticationId)} is missing in AzureLogAnalyticsOptions");
            }

            var loggerConfiguration = sinkBuilderContext
                                      .LoggerConfiguration
                                      .WriteTo
                                      .AzureAnalytics(options.WorkspaceId, options.AuthenticationId, logName: options.LogName);

            // TODO: Sanitization of the LogName

            return(sinkBuilderContext.Clone(loggerConfiguration));
        }
Exemple #4
0
        public static ISinkBuilderContext UseSeq(this ISinkBuilderContext sinkBuilderContext, string serverUrl, Action <ISetApiKey> configure)
        {
            var builder = new FluentSeqSinkBuilder(sinkBuilderContext, serverUrl);

            configure(builder);

            return(builder.BuildAndCloneContext(sinkBuilderContext));
        }
Exemple #5
0
        public static ISinkBuilderContext UseLogEntries(this ISinkBuilderContext sinkBuilderContext, string token, Action <IProvideTemplate> configure)
        {
            var builder = new FluentLogEntriesSinkBuilder(sinkBuilderContext, token);

            configure(builder);

            return(builder.BuildAndCloneContext(sinkBuilderContext));
        }
Exemple #6
0
        public FluentSeqSinkBuilder(ISinkBuilderContext sinkBuilderContext, string serverUrl)
        {
            if (string.IsNullOrWhiteSpace(serverUrl))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(serverUrl));
            }

            _sinkBuilderContext =
                sinkBuilderContext ?? throw new ArgumentNullException(nameof(sinkBuilderContext));
            _serverUrl = serverUrl;
        }
        public FluentLogEntriesSinkBuilder(ISinkBuilderContext sinkBuilderContext, string apiToken)
        {
            if (string.IsNullOrWhiteSpace(apiToken))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(apiToken));
            }

            _sinkBuilderContext = sinkBuilderContext ??
                                  throw new ArgumentNullException(nameof(sinkBuilderContext));
            _apiToken = apiToken;
        }
        public static ISinkBuilderContext UseAzureTableStorage(this ISinkBuilderContext sinkBuilderContext, IConfiguration configuration, Action <AzureTableStorageOptions> configure = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var options = new AzureTableStorageOptions();

            configuration.GetSection(nameof(AzureTableStorageOptions)).Bind(options);
            configure?.Invoke(options);

            if (string.IsNullOrWhiteSpace(options.ConnectionString))
            {
                throw new ArgumentException($"{nameof(options.ConnectionString)} is missing in AzureTableStorageOptions");
            }

            var loggerConfiguration = sinkBuilderContext.LoggerConfiguration.WriteTo.AzureTableStorage(options.ConnectionString);

            return(sinkBuilderContext.Clone(loggerConfiguration));
        }
Exemple #9
0
        public static ISinkBuilderContext UseLoggly(this ISinkBuilderContext sinkBuilderContext, string serverUrl, Action <ISetCustomerToken> configure)
        {
            if (sinkBuilderContext == null)
            {
                throw new ArgumentNullException(nameof(sinkBuilderContext));
            }
            if (serverUrl == null)
            {
                throw new ArgumentNullException(nameof(serverUrl));
            }
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var serverUri = new Uri(serverUrl, UriKind.Absolute);
            var builder   = new FluentLogglySinkBuilder(sinkBuilderContext, serverUri);

            configure(builder);

            return(builder.BuildAndCloneContext(sinkBuilderContext));
        }
Exemple #10
0
        public static ISinkBuilderContext BuildAndCloneContext(this ISinkBuilder builder, ISinkBuilderContext sinkBuilderContext)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (sinkBuilderContext == null)
            {
                throw new ArgumentNullException(nameof(sinkBuilderContext));
            }

            var loggerConfiguration = builder.Build();

            return(sinkBuilderContext.Clone(loggerConfiguration));
        }
Exemple #11
0
 public FluentLogglySinkBuilder(ISinkBuilderContext sinkBuilderContext, Uri serverUri)
 {
     _sinkBuilderContext =
         sinkBuilderContext ?? throw new ArgumentNullException(nameof(sinkBuilderContext));
     _serverUri = serverUri ?? throw new ArgumentNullException(nameof(serverUri));
 }