Пример #1
0
        private string FormatText(SemanticLogLevel logLevel, Exception?exception, LogFormatter action)
        {
            var writer = writerFactory.Create();

            try
            {
                writer.WriteProperty(nameof(logLevel), logLevel.ToString());

                action(writer);

                for (var i = 0; i < appenders.Length; i++)
                {
                    appenders[i].Append(writer, logLevel, exception);
                }

                writer.WriteException(exception);

                return(writer.ToString());
            }
            finally
            {
                writerFactory.Release(writer);
            }
        }
Пример #2
0
        private string FormatText <T>(SemanticLogLevel logLevel, T context, Action <T, IObjectWriter> objectWriter)
        {
            var writer = writerFactory.Create();

            try
            {
                writer.WriteProperty(nameof(logLevel), logLevel.ToString());

                objectWriter(context, writer);

                for (var i = 0; i < appenders.Length; i++)
                {
                    appenders[i].Append(writer, logLevel);
                }

                return(writer.ToString());
            }
            finally
            {
                writerFactory.Release(writer);
            }
        }