private void ParseProperties(PatternParser patternParser) { if (!_parsedProperties) { _parsedDimensions = !_dimensions.Any() ? null : _dimensions .Select(x => new Dimension { Name = x.Key, Value = patternParser.Parse(x.Value.Value) }). ToDictionary(x => x.Name, y => y); _parsedUnit = String.IsNullOrEmpty(Unit) ? null : patternParser.Parse(Unit); _parsedNamespace = string.IsNullOrEmpty(Namespace) ? null : patternParser.Parse(Namespace); _defaultMetricName = string.IsNullOrEmpty(MetricName) ? null : patternParser.Parse(MetricName); _dateTimeOffset = string.IsNullOrEmpty(Timestamp) ? null : (DateTimeOffset?)DateTimeOffset.Parse(patternParser.Parse(Timestamp)); _parsedProperties = true; } }
protected override void Append(LoggingEvent loggingEvent) { System.Diagnostics.Debug.WriteLine("Appending"); if (!_eventRateLimiter.Request(loggingEvent.TimeStamp)) { System.Diagnostics.Debug.WriteLine("Appending denied due to event saturation."); return; } if (Layout == null) Layout = new PatternLayout("%message"); var renderedString = RenderLoggingEvent(loggingEvent); var patternParser = new PatternParser(loggingEvent); if (renderedString.Contains("%")) renderedString = patternParser.Parse(renderedString); System.Diagnostics.Debug.WriteLine(string.Format("RenderedString: {0}", renderedString)); ParseProperties(patternParser); var parser = new EventMessageParser(renderedString, ConfigOverrides) { DefaultMetricName = _defaultMetricName, DefaultNameSpace = _parsedNamespace, DefaultUnit = _parsedUnit, DefaultDimensions = _parsedDimensions, DefaultTimestamp = _dateTimeOffset }; if (!string.IsNullOrEmpty(Value) && ConfigOverrides) parser.DefaultValue = Double.Parse(Value, CultureInfo.InvariantCulture); parser.Parse(); foreach (var putMetricDataRequest in parser) SendItOff(putMetricDataRequest); }