Ejemplo n.º 1
0
        public static void Notify(ILogger[] loggers)
        {
            if (loggers == null || !loggers.Any())
            {
                return;
            }

            if (KissLogConfiguration.Listeners == null || KissLogConfiguration.Listeners.Any() == false)
            {
                return;
            }

            Logger[] theLoggers = loggers.OfType <Logger>().ToArray();

            if (!theLoggers.Any())
            {
                return;
            }

            Logger defaultLogger = theLoggers.FirstOrDefault(p => p.CategoryName == Logger.DefaultCategoryName) ?? theLoggers.First();

            ArgsResult argsResult = CreateArgs(theLoggers);

            FlushLogArgs      defaultArgs  = argsResult.Args;
            List <LoggerFile> defaultFiles = argsResult.Files.ToList();

            string defaultArgsJsonJson = JsonConvert.SerializeObject(defaultArgs);

            foreach (ILogListener listener in KissLogConfiguration.Listeners)
            {
                FlushLogArgs args = CreateFlushArgsForListener(defaultLogger, listener, defaultArgs, defaultArgsJsonJson, defaultFiles.ToList());

                if (ShouldUseListener(listener, args) == false)
                {
                    continue;
                }

                listener.Parser?.BeforeFlush(args, listener);

                listener.OnFlush(args);
            }

            foreach (Logger logger in theLoggers)
            {
                logger.Reset();
            }
        }
Ejemplo n.º 2
0
        public static FlushLogArgs CreateFlushArgs(ILogger[] loggers)
        {
            ArgsResult args = KissLog.NotifyListeners.CreateArgs(loggers);

            return(args?.Args);
        }
Ejemplo n.º 3
0
        public static FlushLogArgs CreateFlushArgs(ILogger[] loggers)
        {
            ArgsResult args = NotifyOnFlushService.CreateArgs(loggers);

            return(args?.Args);
        }