int RenderValue(HtmlTheme theme, ThemedValueFormatter valueFormatter, LogEventPropertyValue propertyValue, TextWriter output, string format) { if (_isLiteral && propertyValue is ScalarValue sv && sv.Value is string) { using (theme.Apply(output, HtmlThemeStyle.String)) output.Write(sv.Value); return(0); } return(valueFormatter.Format(propertyValue, output, format, _isLiteral)); }
public override void Render(LogEvent logEvent, TextWriter output) { var moniker = LevelOutputFormat.GetLevelMoniker(logEvent.Level, _levelToken.Format); if (!Levels.TryGetValue(logEvent.Level, out var levelStyle)) { levelStyle = HtmlThemeStyle.Invalid; } using (_theme.Apply(output, levelStyle)) Padding.Apply(output, moniker, _levelToken.Alignment); }
public override void Render(LogEvent logEvent, TextWriter output) { // Padding is never applied by this renderer. if (logEvent.Exception is null) { return; } var lines = new StringReader(logEvent.Exception.ToString()); string nextLine; while ((nextLine = lines.ReadLine()) != null) { var style = nextLine.StartsWith(StackFrameLinePrefix) ? HtmlThemeStyle.SecondaryText : HtmlThemeStyle.Text; using (_theme.Apply(output, style)) output.WriteLine(nextLine); } }
public override void Render(LogEvent logEvent, TextWriter output) { // If a property is missing, don't render anything (message templates render the raw token here). if (!logEvent.Properties.TryGetValue(_token.PropertyName, out var propertyValue)) { Padding.Apply(output, string.Empty, _token.Alignment); return; } using (_theme.Apply(output, HtmlThemeStyle.SecondaryText)) { var writer = _token.Alignment.HasValue ? new StringWriter() : output; // If the value is a scalar string, support some additional formats: 'u' for uppercase // and 'w' for lowercase. if (propertyValue is ScalarValue sv && sv.Value is string literalString) { var cased = Casing.Format(literalString, _token.Format); writer.Write(cased); }
public override void Render(LogEvent logEvent, TextWriter output) { // We need access to ScalarValue.Render() to avoid this alloc; just ensures // that custom format providers are supported properly. var sv = new ScalarValue(logEvent.Timestamp); using (_theme.Apply(output, HtmlThemeStyle.SecondaryText)) { if (_token.Alignment is null) { sv.Render(output, _token.Format); } else { var buffer = new StringWriter(); sv.Render(buffer, _token.Format); var str = buffer.ToString(); Padding.Apply(output, str, _token.Alignment); } } }
protected StyleReset ApplyStyle(TextWriter output, HtmlThemeStyle style) { return(_theme.Apply(output, style)); }
int RenderTextToken(TextToken tt, TextWriter output) { using (_theme.Apply(output, HtmlThemeStyle.Text)) output.Write(tt.Text); return(0); }
public override void Render(LogEvent logEvent, TextWriter output) { using (_theme.Apply(output, HtmlThemeStyle.TertiaryText)) output.Write(_text); }