public TableLoggerProvider(AzureLoggerSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } this.settings = settings; var cloud = CloudStorageAccount.Parse(settings.ConnectionString); this.client = cloud.CreateCloudTableClient(); this.table = client.GetTableReference(settings.Table); this.blobClient = cloud.CreateCloudBlobClient(); if (!string.IsNullOrEmpty(settings.OverflowContainer)) { this.container = this.blobClient.GetContainerReference(settings.OverflowContainer); } this.batchBlock = new BatchBlock <DynamicTableEntity>(25); Timer triggerBatchTimer = new Timer((_) => this.batchBlock.TriggerBatch(), null, Timeout.Infinite, Timeout.Infinite); pipeline = new TransformBlock <DynamicTableEntity, DynamicTableEntity>((value) => { triggerBatchTimer.Change(5000, Timeout.Infinite); return(value); }); pipelineEnd = new ActionBlock <DynamicTableEntity[]>(WriteBatch); pipeline.LinkTo(batchBlock); batchBlock.LinkTo(pipelineEnd); this.overflowBlock = new ActionBlock <KeyValuePair <string, string> >(WriteOverflow); }
private Func <string, Microsoft.Extensions.Logging.LogLevel, bool> GetFilter(string name, AzureLoggerSettings settings) { if (filter != null) { return(filter); } if (settings != null) { foreach (var prefix in GetKeyPrefixes(name)) { Microsoft.Extensions.Logging.LogLevel level; if (settings.TryGetSwitch(prefix, out level)) { this.filter = (n, l) => l >= level; return(this.filter); } } } this.filter = (n, l) => false; return(this.filter); }