Logger

Namespace: jsnlog
We found 10 examples in language CSharp for this search. You will see 47 fragments of code.

		[Test]
		public void Closed ()
		{
			_form = new Form ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (0, logger.CountEvents ("Closed"), "#1");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#2");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#3");
		}

		[Test]
		public void Closed_Dialog ()
		{
			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#1");
			_form.ShowDialog ();
			Assert.AreEqual (2, logger.CountEvents ("Closed"), "#2");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (2, logger.CountEvents ("Closed"), "#3");
		}

		[Test]
		public void Closing ()
		{
			_form = new Form ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (0, logger.CountEvents ("Closing"), "#1");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#2");
		}

		[Test]
		public void Closing_Dialog ()
		{
			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#1");
			_form.ShowDialog ();
			Assert.AreEqual (2, logger.CountEvents ("Closing"), "#2");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (2, logger.CountEvents ("Closing"), "#3");
		}

		[Test]
		public void FormClosing_Dialog ()
		{
			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("FormClosing"));
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"));
			_form.ShowDialog ();
			Assert.AreEqual (2, logger.CountEvents ("FormClosing"));
		}

		[Test]
		public void Load_Dialog ()
		{
			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("Load"), "#1");
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#2");
			_form.ShowDialog ();
			Assert.AreEqual (2, logger.CountEvents ("Load"), "#3");
		}


		void CheckLoggedMessagesInOrder (TestMessageLogger logger, string [] values, string prefix)
		{
			try {
				for (int i = 0; i < values.Length; i++) {
					logger.CheckLoggedMessageHead (values [i], prefix + "#" + i);
				}
				if (logger.NormalMessageCount > 0)
					Assert.Fail ("{0}: Expected {1} messages, but found {2}",
						prefix, values.Length, values.Length + logger.NormalMessageCount);
			} catch (NUnit.Framework.AssertionException) {
				logger.DumpMessages ();
				throw;
			}
		}

		void CheckMessage (TestMessageLogger logger, string culture, string items, string id)
		{
			logger.CheckLoggedMessageHead (String.Format ("Culture: {0} -- ResXFile: {1}", culture, items), id);
		}

		void CheckMessage2 (TestMessageLogger logger, string culture, string resx_files, string nonresx_files, string id)
		{
			logger.CheckLoggedMessageHead (String.Format ("Culture: {0} -- ResXFiles: {1} NonResXFiles: {2}", culture, resx_files, nonresx_files), id);
		}

		void CheckLoggedMessageAny (TestMessageLogger logger, string expected, string id)
		{
			if (logger.CheckAny (expected, MessageImportance.Normal) == 1)
				Assert.Fail ("{0}: Expected message '{1}' was not emitted.", id, expected);
		}

        Logger CreateLogger();
            public Logger CreateLogger()
            {
                return GetCurrentLogger();
            }

            public Logger CreateLogger()
            {
                return LogManager.GetLogger(_loggerName);
            }

            public Logger CreateLogger()
            {
                return LogManager.GetCurrentClassLogger(_type);
            }


        /// <summary>
        /// Set the parent for logger object
        /// </summary>
        /// <param name="logger">logger whose parent is to be set</param>
        /// <param name="parent">parent logger</param>
        private static void DoSetParent(Logger logger, Logger parent)
        {
            logger.SetParent(parent);
        }

        /// <summary>
        /// Get the looger by name
        /// </summary>
        /// <param name="name">name of the logger</param>
        /// <returns>Logger Object</returns>
        public Logger GetLogger(string name)
        {
            if (loggers.ContainsKey(name))
                return loggers[name];
            else
                return null;
        }

        /// <summary>
        /// Get an enumeration of known logger names.
        /// </summary>
        /// <returns>enumeration of logger name strings</returns>
        [MethodImpl(MethodImplOptions.Synchronized)]
        public Dictionary<String, Logger> GetLoggerNames()
        {
            return loggers;
        }

#if NETFULL
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Utilities.Logging
{
    public static class Log
    {
        private static IEnumerable<ILogger> _loggers;
        private static readonly Object _lock = new Object();


        public static void Write(String message)
        {
            Initialize();

            SimpleLoggerEntry entry = new SimpleLoggerEntry(message);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    logger.Write(entry);
                }
            }
        }

        public static void Write(Exception ex)
        {
            Initialize();

            ExceptionLoggerEntry entry = new ExceptionLoggerEntry(ex);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    logger.Write(entry);
                }
            }
        }

        public static void Write(ILoggerEntry entry)
        {
            Initialize();

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    logger.Write(entry);
                }
            }
        }


        public static void WriteToFile(String message)
        {
            Initialize();

            SimpleLoggerEntry entry = new SimpleLoggerEntry(message);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is FileLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToFile(Exception ex)
        {
            Initialize();

            ExceptionLoggerEntry entry = new ExceptionLoggerEntry(ex);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is FileLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToFile(ILoggerEntry entry)
        {
            Initialize();

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is FileLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }


        public static void WriteToEventLog(String message)
        {
            Initialize();

            SimpleLoggerEntry entry = new SimpleLoggerEntry(message);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is EventLogLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToEventLog(Exception ex)
        {
            Initialize();

            ExceptionLoggerEntry entry = new ExceptionLoggerEntry(ex);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is EventLogLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToEventLog(ILoggerEntry entry)
        {
            Initialize();

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is EventLogLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }


        public static void WriteToMail(String message)
        {
            Initialize();

            SimpleLoggerEntry entry = new SimpleLoggerEntry(message);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is MailLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToMail(Exception ex)
        {
            Initialize();

            ExceptionLoggerEntry entry = new ExceptionLoggerEntry(ex);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is MailLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToMail(ILoggerEntry entry)
        {
            Initialize();

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is MailLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }


        public static void WriteToConsole(String message)
        {
            Initialize();

            SimpleLoggerEntry entry = new SimpleLoggerEntry(message);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is ConsoleLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToConsole(Exception ex)
        {
            Initialize();

            ExceptionLoggerEntry entry = new ExceptionLoggerEntry(ex);

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is ConsoleLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }

        public static void WriteToConsole(ILoggerEntry entry)
        {
            Initialize();

            lock (_lock)
            {
                foreach (ILogger logger in _loggers)
                {
                    if (logger is ConsoleLogger)
                    {
                        logger.Write(entry);
                    }
                }
            }
        }


        private static void Initialize()
        {
            _loggers = ConfigurationManager.GetSection("utilities/logging") as IEnumerable<ILogger>;

            if (_loggers == null)
            {
                throw new ArgumentNullException("utilities/logging", "Section is not exists!");
            }
        }
    }
}
#endif


        [SetUp]
        public void Setup()
        {
            mockLogger = new MockLogger();
            Logger.Instance.AddLogger(mockLogger);
        }

        [TearDown]
        public void Teardown()
        {
            Logger.Instance.RemoveLogger(mockLogger);
        }

        [Test]
        public void Test()
        {
            var logger = Logger.Instance;

            logger.Info("Test Info");
            Assert.AreEqual("Test Info", mockLogger.infoQueue.Dequeue());
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);

            logger.Warn("Test Warn");
            Assert.AreEqual("Test Warn", mockLogger.warnQueue.Dequeue());
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);

            logger.Error("Test Error");
            Assert.AreEqual("Test Error", mockLogger.errorQueue.Dequeue());
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);

            logger.Debug("Test Debug");
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);

            logger.Level = LogLevel.Debug;
            Assert.IsTrue(mockLogger.IsDebugEnabled);
            Assert.IsTrue(mockLogger.IsInfoEnabled);
            Assert.IsTrue(mockLogger.IsWarnEnabled);
            Assert.IsTrue(mockLogger.IsErrorEnabled);

            logger.Info("Test Info");
            Assert.AreEqual("Test Info", mockLogger.infoQueue.Dequeue());
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);

            logger.Warn("Test Warn");
            Assert.AreEqual("Test Warn", mockLogger.warnQueue.Dequeue());
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);

            logger.Error("Test Error");
            Assert.AreEqual("Test Error", mockLogger.errorQueue.Dequeue());
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);

            logger.Debug("Test Debug");
            Assert.AreEqual("Test Debug", mockLogger.debugQueue.Dequeue());
            Assert.AreEqual(0, mockLogger.debugQueue.Count);
            Assert.AreEqual(0, mockLogger.infoQueue.Count);
            Assert.AreEqual(0, mockLogger.warnQueue.Count);
            Assert.AreEqual(0, mockLogger.errorQueue.Count);
        }

            #region Overrides of AbstractLogger

            protected override void DebugOverride(string message)
            {
                debugQueue.Enqueue(message);
            }

            protected override void InfoOverride(string message)
            {
                infoQueue.Enqueue(message);
            }

            protected override void WarnOverride(string message)
            {
                warnQueue.Enqueue(message);
            }

        [Fact]
        public void BasicTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            NoNamespace.CouldNotOpenSocket(logger, "microsoft.com");
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Null(logger.LastException);
            Assert.Equal("Could not open socket to `microsoft.com`", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            Level1.OneLevelNamespace.CouldNotOpenSocket(logger, "microsoft.com");
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Null(logger.LastException);
            Assert.Equal("Could not open socket to `microsoft.com`", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            Level1.Level2.TwoLevelNamespace.CouldNotOpenSocket(logger, "microsoft.com");
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Null(logger.LastException);
            Assert.Equal("Could not open socket to `microsoft.com`", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);
        }

        [Fact]
        public void EnableTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            logger.Enabled = false;
            NoNamespace.CouldNotOpenSocket(logger, "microsoft.com");
            Assert.Equal(0, logger.CallCount);          // ensure the logger doesn't get called when it is disabled
        }

        [Fact]
        public void ArgTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            ArgTestExtensions.Method1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M1", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method2(logger, "arg1");
            Assert.Null(logger.LastException);
            Assert.Equal("M2 arg1", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method3(logger, "arg1", 2);
            Assert.Null(logger.LastException);
            Assert.Equal("M3 arg1 2", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method4(logger, new InvalidOperationException("A"));
            Assert.Equal("A", logger.LastException!.Message);
            Assert.Equal("M4", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method5(logger, new InvalidOperationException("A"), new InvalidOperationException("B"));
            Assert.Equal("A", logger.LastException!.Message);
            Assert.Equal("M5 System.InvalidOperationException: B", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method6(logger, new InvalidOperationException("A"), 2);
            Assert.Equal("A", logger.LastException!.Message);
            Assert.Equal("M6 2", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method7(logger, 1, new InvalidOperationException("B"));
            Assert.Equal("B", logger.LastException!.Message);
            Assert.Equal("M7 1", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method8(logger, 1, 2, 3, 4, 5, 6, 7);
            Assert.Equal("M81234567", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method9(logger, 1, 2, 3, 4, 5, 6, 7);
            Assert.Equal("M9 1 2 3 4 5 6 7", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method10(logger, 1);
            Assert.Equal("M101", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);
        }

        [Fact]
        public void CollectionTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            CollectionTestExtensions.M0(logger);
            TestCollection(1, logger);

            logger.Reset();
            CollectionTestExtensions.M1(logger, 0);
            TestCollection(2, logger);

            logger.Reset();
            CollectionTestExtensions.M2(logger, 0, 1);
            TestCollection(3, logger);

            logger.Reset();
            CollectionTestExtensions.M3(logger, 0, 1, 2);
            TestCollection(4, logger);

            logger.Reset();
            CollectionTestExtensions.M4(logger, 0, 1, 2, 3);
            TestCollection(5, logger);

            logger.Reset();
            CollectionTestExtensions.M5(logger, 0, 1, 2, 3, 4);
            TestCollection(6, logger);

            logger.Reset();
            CollectionTestExtensions.M6(logger, 0, 1, 2, 3, 4, 5);
            TestCollection(7, logger);

            logger.Reset();
            CollectionTestExtensions.M7(logger, 0, 1, 2, 3, 4, 5, 6);
            TestCollection(8, logger);

            logger.Reset();
            CollectionTestExtensions.M8(logger, 0, 1, 2, 3, 4, 5, 6, 7);
            TestCollection(9, logger);

            logger.Reset();
            CollectionTestExtensions.M9(logger, LogLevel.Critical, 0, new ArgumentException("Foo"), 1);
            TestCollection(3, logger);

            Assert.True(true);
        }

        [Fact]
        public void MessageTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            MessageTestExtensions.M0(logger);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M5(logger, LogLevel.Trace);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(-1, logger.LastEventId.Id);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M6(logger, LogLevel.Trace);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(6, logger.LastEventId.Id);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M7(logger, LogLevel.Trace, "p", "q");
            Assert.Null(logger.LastException);
            Assert.Equal("\"p\" -> \"q\"", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(7, logger.LastEventId.Id);
            Assert.Equal(1, logger.CallCount);
        }

        [Fact]
        [ActiveIssue("https://github.com/dotnet/roslyn/issues/52527")]
        public void MessageTests_SuppressWarning_WarnAsError_NoError()
        {
            // Diagnostics produced by source generators do not respect the /warnAsError or /noWarn compiler flags.
            // These are handled fine by the logger generator and generate warnings. Unfortunately, the warning suppression is
            // not being observed by the C# compiler at the moment, so having these here causes build warnings.
#if false
            var logger = new MockLogger();

            logger.Reset();
            MessageTestExtensions.M2(logger, "Foo", "Bar");
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            AssertLastState(logger,
                new KeyValuePair<string, object?>("p1", "Foo"),
                new KeyValuePair<string, object?>("p2", "Bar"),
                new KeyValuePair<string, object?>("{OriginalFormat}", string.Empty));
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M3(logger, "Foo", 42);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            AssertLastState(logger,
                new KeyValuePair<string, object?>("p1", "Foo"),
                new KeyValuePair<string, object?>("p2", 42),
                new KeyValuePair<string, object?>("{OriginalFormat}", string.Empty));
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
#endif
        }

        [Fact]
        public void GetLoggerWithServices_ReturnsCompositeExceptionLoggerWithServicesLoggers()
        {
            // Arrange
            IExceptionLogger expectedLogger = CreateDummyLogger();

            using (ServicesContainer services = CreateServices(expectedLogger))
            {
                // Act
                IExceptionLogger logger = ExceptionServices.GetLogger(services);

                // Assert
                Assert.IsType<CompositeExceptionLogger>(logger);
                IEnumerable<IExceptionLogger> loggers = ((CompositeExceptionLogger)logger).Loggers;
                Assert.Equal(1, loggers.Count());
                Assert.Same(expectedLogger, loggers.Single());
            }
        }

        [Fact]
        public void GetLoggerWithServices_ReturnsSameInstance()
        {
            // Arrange
            IExceptionLogger innerLogger = CreateDummyLogger();

            using (ServicesContainer services = CreateServices(innerLogger))
            {
                IExceptionLogger firstLogger = ExceptionServices.GetLogger(services);

                // Act
                IExceptionLogger secondLogger = ExceptionServices.GetLogger(services);

                // Assert
                Assert.Same(firstLogger, secondLogger);
            }
        }

        [Fact]
        public void GetLoggerWithServices_IfServicesIsNull_Throws()
        {
            // Arrange
            ServicesContainer services = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => ExceptionServices.GetLogger(services), "services");
        }

        [Fact]
        public void GetLoggerWithConfiguration_ReturnsCompositeExceptionLoggerWithServicesLoggers()
        {
            // Arrange
            IExceptionLogger expectedLogger = CreateDummyLogger();

            using (HttpConfiguration configuration = CreateConfiguration(expectedLogger))
            {
                // Act
                IExceptionLogger logger = ExceptionServices.GetLogger(configuration);

                // Assert
                Assert.IsType<CompositeExceptionLogger>(logger);
                IEnumerable<IExceptionLogger> loggers = ((CompositeExceptionLogger)logger).Loggers;
                Assert.Equal(1, loggers.Count());
                Assert.Same(expectedLogger, loggers.Single());
            }
        }

        [Fact]
        public void GetLoggerWithConfiguration_IfConfigurationIsNull_Throws()
        {
            // Arrange
            HttpConfiguration configuration = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => ExceptionServices.GetLogger(configuration), "configuration");
        }

        [Fact]
        public void GetHandlerWithServices_ReturnsLastChanceHandlerWithServicesInnerHandler()
        {
            // Arrange
            IExceptionHandler expectedHandler = CreateDummyHandler();

            using (ServicesContainer services = CreateServices(expectedHandler))
            {
                // Act
                IExceptionHandler handler = ExceptionServices.GetHandler(services);

                // Assert
                Assert.IsType<LastChanceExceptionHandler>(handler);
                IExceptionHandler innerHandler = ((LastChanceExceptionHandler)handler).InnerHandler;
                Assert.Same(expectedHandler, innerHandler);
            }
        }


        public static AggregateLogger Create(params ILogger[] loggers)
        {
            var set = new HashSet<ILogger>();

            // flatten loggers
            foreach (var logger in loggers.WhereNotNull())
            {
                if (logger is AggregateLogger aggregateLogger)
                {
                    set.UnionWith(aggregateLogger._loggers);
                    continue;
                }

                set.Add(logger);
            }

            return new AggregateLogger(set.ToImmutableArray());
        }

        public static ILogger AddOrReplace(ILogger newLogger, ILogger oldLogger, Func<ILogger, bool> predicate)
        {
            if (newLogger == null)
            {
                return oldLogger;
            }

            if (oldLogger == null)
            {
                return newLogger;
            }

            var aggregateLogger = oldLogger as AggregateLogger;
            if (aggregateLogger == null)
            {
                // replace old logger with new logger
                if (predicate(oldLogger))
                {
                    // this might not aggregate logger
                    return newLogger;
                }

                // merge two
                return new AggregateLogger(ImmutableArray.Create(newLogger, oldLogger));
            }

            var set = new HashSet<ILogger>();
            foreach (var logger in aggregateLogger._loggers)
            {
                // replace this logger with new logger
                if (predicate(logger))
                {
                    set.Add(newLogger);
                    continue;
                }

                // add old one back
                set.Add(logger);
            }

            // add new logger. if we already added one, this will be ignored.
            set.Add(newLogger);
            return new AggregateLogger(set.ToImmutableArray());
        }

        public static ILogger Remove(ILogger logger, Func<ILogger, bool> predicate)
        {
            var aggregateLogger = logger as AggregateLogger;
            if (aggregateLogger == null)
            {
                // remove the logger
                if (predicate(logger))
                {
                    return null;
                }

                return logger;
            }

            // filter out loggers
            var set = aggregateLogger._loggers.Where(l => !predicate(l)).ToSet();
            if (set.Count == 1)
            {
                return set.Single();
            }

            return new AggregateLogger(set.ToImmutableArray());
        }

        public bool IsEnabled(FunctionId functionId)
        {
            return true;
        }

        public void Log(FunctionId functionId, LogMessage logMessage)
        {
            for (var i = 0; i < _loggers.Length; i++)
            {
                var logger = _loggers[i];
                if (!logger.IsEnabled(functionId))
                {
                    continue;
                }

                logger.Log(functionId, logMessage);
            }
        }

        public void LogBlockStart(FunctionId functionId, LogMessage logMessage, int uniquePairId, CancellationToken cancellationToken)
        {
            for (var i = 0; i < _loggers.Length; i++)
            {
                var logger = _loggers[i];
                if (!logger.IsEnabled(functionId))
                {
                    continue;
                }

                logger.LogBlockStart(functionId, logMessage, uniquePairId, cancellationToken);
            }
        }


	public static PerfTimerLogger Get(string message)
	{
		if (PerfTimerLogger._instances == null || !PerfTimerLogger._instances.ContainsKey(message))
		{
			return null;
		}
		return PerfTimerLogger._instances[message];
	}

	public void Pause()
	{
		this._timer.Stop();
	}

	public void Unpause()
	{
		this._timer.Start();
	}

	public void Stop()
	{
		this.Dispose();
	}

	public void Dispose()
	{
		this._timer.Stop();
		long elapsedMilliseconds = this._timer.ElapsedMilliseconds;
		long elapsedTicks = this._timer.ElapsedTicks;
		PerfTimerLogger.LogResultType logResultType = this._logResultType;
		string text;
		if (logResultType != PerfTimerLogger.LogResultType.Ticks)
		{
			text = string.Format("{0} - Elapsed Milliseconds: {1}", this._message, elapsedMilliseconds);
		}
		else
		{
			text = string.Format("{0} - Elapsed Ticks: {1}", this._message, elapsedTicks);
		}
		if (this._logAction != null)
		{
			this._logAction(text);
		}
		else
		{
			UnityEngine.Debug.Log(text);
		}
		if (PerfTimerLogger._instances != null && PerfTimerLogger._instances.ContainsKey(this._message))
		{
			PerfTimerLogger._instances.Remove(this._message);
		}
	}

JSNLog.Logger : ICanCreateJsonFields, ICanCreateElement

Constructors :

public Logger()

Methods :

public String get_appenders()
public Void set_appenders(String value = )
public String get_name()
public Void set_name(String value = )
public List<OnceOnlyOptions> get_onceOnlies()
public Void set_onceOnlies(List<OnceOnlyOptions> value = )
public Void CreateElement(StringBuilder sb = , Dictionary<StringString> appenderNames = , Int32 sequence = , Func<StringString> virtualToAbsoluteFunc = )
public Void AddJsonFields(IList<String> jsonFields = , Dictionary<StringString> appenderNames = , Func<StringString> virtualToAbsoluteFunc = )
public String get_level()
public Void set_level(String value = )
public String get_ipRegex()
public Void set_ipRegex(String value = )
public String get_userAgentRegex()
public Void set_userAgentRegex(String value = )
public String get_disallow()
public Void set_disallow(String value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods