Example #1
0
        private static void Notify(FlushLogArgs args, LogListenerDecorator decorator, Guid?httpRequestId)
        {
            if (httpRequestId != null && decorator.SkipHttpRequestIds.Contains(httpRequestId.Value))
            {
                return;
            }

            ILogListener listener = decorator.Listener;

            if (listener.Interceptor != null && listener.Interceptor.ShouldLog(args, listener) == false)
            {
                return;
            }

            FlushLogArgs argsForListener = CreateArgsForListener(args, listener);

            listener.OnFlush(argsForListener);
        }
 public void OnFlush(FlushLogArgs args)
 {
     _textListener.OnFlush(args);
 }
Example #3
0
        public static void Notify(ILogger[] loggers)
        {
            if (loggers == null || !loggers.Any())
            {
                return;
            }

            if (KissLogConfiguration.Listeners.Get().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 (LogListenerDecorator decorator in KissLogConfiguration.Listeners.Get())
            {
                ILogListener listener = decorator.Listener;

                if (decorator.ShouldSkipOnFlush(defaultArgs.WebProperties.Request))
                {
                    continue;
                }

                FlushLogArgs args = CreateFlushArgsForListener(defaultLogger, listener, defaultArgs, defaultArgsJsonJson, defaultFiles.ToList());

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

                if (listener.Parser != null)
                {
                    listener.Parser.BeforeFlush(args, listener);
                }

                listener.OnFlush(args, defaultLogger);
            }

            foreach (Logger logger in theLoggers)
            {
                logger.Reset();
            }

            foreach (LogListenerDecorator decorator in KissLogConfiguration.Listeners.Get())
            {
                decorator.Reset();
            }
        }