Exemple #1
0
        private int RenderTextToken(TextToken tt, TextWriter output)
        {
            var count = 0;

            using (_theme.Apply(output, RichTextBoxThemeStyle.Text, ref count))
            {
                var text = SpecialCharsEscaping.Apply(tt.Text, ref count);
                output.Write(text);
            }

            return(count);
        }
        public override void Render(LogEvent logEvent, TextWriter output)
        {
            var _ = 0;
            var text = _text;

            using (_theme.Apply(output, RichTextBoxThemeStyle.TertiaryText, ref _))
            {
                text = SpecialCharsEscaping.Apply(text, ref _);
                output.Write(text);
            }
        }
Exemple #3
0
        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 = RichTextBoxThemeStyle.Invalid;
            }

            var _ = 0;

            using (_theme.Apply(output, levelStyle, ref _))
            {
                Padding.Apply(output, moniker, _levelToken.Alignment);
            }
        }
Exemple #4
0
        private int RenderValue(RichTextBoxTheme theme, ThemedValueFormatter valueFormatter, LogEventPropertyValue propertyValue, TextWriter output, string format)
        {
            if (_isLiteral && propertyValue is ScalarValue {
                Value : string
            } sv)
            {
                var count = 0;
                using (theme.Apply(output, RichTextBoxThemeStyle.String, ref count))
                {
                    var text = SpecialCharsEscaping.Apply(sv.Value.ToString(), ref count);
                    output.Write(text);
                }

                return(count);
            }

            return(valueFormatter.Format(propertyValue, output, format, _isLiteral));
        }
Exemple #5
0
        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;
            }

            var _ = 0;

            using (_theme.Apply(output, RichTextBoxThemeStyle.SecondaryText, ref _))
            {
                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 {
                    Value : string literalString
                })
Exemple #6
0
        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) ? RichTextBoxThemeStyle.SecondaryText : RichTextBoxThemeStyle.Text;
                var _     = 0;

                using (_theme.Apply(output, style, ref _))
                {
                    output.WriteLine(SpecialCharsEscaping.Apply(nextLine, ref _));
                }
            }
        }
        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);

            var _ = 0;

            using (_theme.Apply(output, RichTextBoxThemeStyle.SecondaryText, ref _))
            {
                if (_token.Alignment is null)
                {
                    sv.Render(output, _token.Format, _formatProvider);
                }
                else
                {
                    var buffer = new StringWriter();
                    sv.Render(buffer, _token.Format, _formatProvider);

                    var str = buffer.ToString();
                    Padding.Apply(output, str, _token.Alignment);
                }
            }
        }
 protected StyleReset ApplyStyle(TextWriter output, RichTextBoxThemeStyle style, ref int invisibleCharacterCount)
 {
     return(_theme.Apply(output, style, ref invisibleCharacterCount));
 }