Пример #1
0
        public static List <ContextSummary> Summarize(IActionContext context)
        {
            var checkpoints = context.GetCheckpoints();
            var summaries   = checkpoints;

            summaries.Add(CreateFromContext(context));

            return(summaries);
        }
Пример #2
0
        private void LogContext(IActionContext context)
        {
            if (context.ShouldSuppress())
            {
                return;
            }

            _memoryLogService.GetPendingMemoryLogs();

            var shouldLog = context.GetCheckpoints().Any() || context.Logger.LogEntries.Any();

            if (!shouldLog)
            {
                return;
            }

            var prefix = _config.ContextLogNamePrefix ?? "context_";

            var summaries = ContextSummary.Summarize(context);

            summaries.ForEach(summary =>
            {
                var contextInfo = summary.Data["contextInfo"] as IRootContextInfo;
                var checkpoint  = contextInfo?.Checkpoint;
                checkpoint      = checkpoint == null ? string.Empty : $"_{checkpoint}";

                summary.Data["contextInfo"] = contextInfo == null
                    ? null
                    : new
                {
                    contextInfo.Checkpoint,
                    contextInfo.Id,
                    contextInfo.ContextName,
                    contextInfo.ContextGroupName
                };

                var logger = LogManager.GetLogger($"{prefix}{context.Info.ContextName}{checkpoint}");

                var entry = CreateLogEntry(
                    logger.Name,
                    context.Info.Id,
                    summary
                    );

                logger.Log(entry);
            });

            LogManager.Flush();

            _memoryLogService.RemoveTimestamp(context.Info.Id);
        }
Пример #3
0
        private void LogContext(IActionContext context)
        {
            var shouldLog = context.GetCheckpoints().Any() || context.Logger.LogEntries.Any();

            if (!shouldLog || context.ShouldSuppress())
            {
                return;
            }

            var summaries = ContextSummary.Summarize(context);
            var logLines  = summaries.Select(s =>
                                             JsonConvert.SerializeObject(s, new Newtonsoft.Json.Converters.StringEnumConverter()));

            logLines.ToList().ForEach(Console.WriteLine);
        }