Exemplo n.º 1
0
        private static void WriteLogEntry <T1, T2, T3>(
            IJsonLogger logger,
            LogSeverity severity,
            T1 arg1,
            T2 arg2,
            T3 arg3,
            Func <Func <string, ILogEntryBuilder>, T1, T2, T3, ILogEntryBuilder> logEntryBuilder,
            string callerFilePath,
            string callerMemberName,
            int callerLineNumber)
        {
            if (callerFilePath == null)
            {
                throw new ArgumentNullException(nameof(callerFilePath));
            }

            if (callerMemberName == null)
            {
                throw new ArgumentNullException(nameof(callerMemberName));
            }

            Instant instant = SystemClock.Instance.GetCurrentInstant();

            logger.AsyncHandler.RunAsync(
                (instantArg, callInfo, a1, a2, a3) =>
            {
                ILogEntryBuilder entryBuilder = logEntryBuilder(
                    msg => new DelegateLogEntryBuilderForLogEntry(
                        e =>
                {
                    e.Message = msg;
                    return(e);
                },
                        logger.SerializerSource),
                    a1,
                    a2,
                    a3);

                var entry = new LogEntry
                {
                    Severity   = severity,
                    Instant    = instant,
                    CallerInfo = callInfo
                };

                object buildedEntry = entryBuilder.Build(entry);
                logger.Log(buildedEntry);
            },
                instant,
                new CallerInfo(callerFilePath, callerMemberName, callerLineNumber),
                arg1,
                arg2,
                arg3);
        }
        /// <inheritdoc/>
        public object Build(object entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            object   currentEntry = _innerBuilder?.Build(entry) ?? entry;
            LogEntry logEntry     = StdJsonLogging.NormalizeToLogEntry(currentEntry, SerializerSource);

            return(_buildDelegate(logEntry));
        }
Exemplo n.º 3
0
 /// <inheritdoc/>
 public void Log(object entry)
 {
     _innerLogger.Log(_builder.Build(entry));
 }