コード例 #1
0
        public void TestThreadSafety()
        {
            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());
            var memoryAppender    = new AppenderMemory();
            var patternLayout     = new LayoutPattern();

            memoryAppender.Layout = patternLayout;
            memoryAppender.Activate();
            BasicConfig.Config(rep, memoryAppender);

            cThreadsRunning = cThreadsMax;
            var threads = Enumerable.Range(0, cThreadsMax)
                          .Select(i => new Thread(LogMessages(rep.Name)))
                          .ToList();

            foreach (var thread in threads)
            {
                thread.Start();
            }

            long cEventsRead = 0;

            while (cThreadsRunning > 0)
            {
                var events = memoryAppender.PopAllInputs();
                cEventsRead += events.Length;
            }
            foreach (var thread in threads)
            {
                thread.Join();
            }
            cEventsRead += memoryAppender.PopAllInputs().Length;
            Assert.AreEqual(cEventsExpected, cEventsRead, "Log events were lost.");
        }
コード例 #2
0
        public void MethodNameCategoryTest()
        {
            CategoryTraceListener categoryTraceListener = new CategoryTraceListener();

            Trace.Listeners.Clear();
            Trace.Listeners.Add(categoryTraceListener);

            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());

            AppenderTrace traceAppender = new AppenderTrace();
            LayoutPattern methodLayout  = new LayoutPattern("%method");

            methodLayout.Activate();
            traceAppender.Category = methodLayout;
            traceAppender.Layout   = new LayoutLoggerSimple();
            traceAppender.Activate();

            BasicConfig.Config(rep, traceAppender);

            ILog log = LogManager.Get(rep.Name, GetType());

            log.Debug("Message");

            Assert.AreEqual(
                System.Reflection.MethodInfo.GetCurrentMethod().Name,
                categoryTraceListener.Category);
        }
コード例 #3
0
        public void NamedPatternConverterWithPrecision2ShouldStripLessLeadingStuffIfPresent()
        {
            StringAppender stringAppender = new StringAppender();
            LayoutPattern  layout         = NewPatternLayout();

            layout.AddConverter("message-as-name", typeof(MessageAsNamePatternConverter));
            layout.Pattern = "%message-as-name{2}";
            layout.Activate();
            stringAppender.Layout = layout;
            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());

            BasicConfig.Config(rep, stringAppender);
            ILog log1 = LogManager.Get(rep.Name, "TestAddingCustomPattern");

            log1.Info("NoDots");
            Assert.AreEqual("NoDots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("One.Dot");
            Assert.AreEqual("One.Dot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("Tw.o.Dots");
            Assert.AreEqual("o.Dots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("TrailingDot.");
            Assert.AreEqual("TrailingDot.", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".LeadingDot");
            Assert.AreEqual("LeadingDot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            // empty string and other evil combinations as tests for of-by-one mistakes in index calculations
            log1.Info(string.Empty);
            Assert.AreEqual(string.Empty, stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("x");
            Assert.AreEqual("x", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".");
            Assert.AreEqual(".", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();
        }
コード例 #4
0
        public void Initialize(LayoutEditorView view, LayoutPattern pattern)
        {
            label_1 :
            int num1 = -541126080;

            while (true)
            {
                int  num2 = -1980269823;
                uint num3;
                switch ((num3 = (uint)(num1 ^ num2)) % 6U)
                {
                case 0:
                    num1 = (int)num3 * 606447693 ^ 2131026100;
                    continue;

                case 1:
                    this.View = (Window)view;
                    num1      = (int)num3 * -1465593818 ^ 7024611;
                    continue;

                case 2:
                    num1 = (int)num3 * 1779913917 ^ -42664494;
                    continue;

                case 3:
                    goto label_3;

                case 4:
                    goto label_1;

                case 5:
                    this.Pattern = pattern;
                    num1         = (int)num3 * -400510196 ^ -1967744957;
                    continue;

                default:
                    goto label_8;
                }
            }
label_8:
            return;

            label_3 :;
        }
コード例 #5
0
        /// <summary>
        /// Creates a logger hierarchy, configures a SMTP pickup dir appender and returns an ILogger
        /// </summary>
        /// <param name="appender">The appender to use</param>
        /// <returns>A configured ILogger</returns>
        private ILogger CreateLogger(AppenderSmtpPickup appender)
        {
            ILoggerController h = LogManager.CreateController("TestRepository");

            LayoutPattern layout = new LayoutPattern();

            layout.Pattern = "%m%n";
            layout.Activate();

            appender.Layout = layout;
            appender.Activate();

            h.Root.AddAppender(appender);
            h.Initialize();

            ILogger log = h.Get("Logger");

            return(log);
        }
コード例 #6
0
        public void TestExceptionPattern()
        {
            StringAppender stringAppender = new StringAppender();
            LayoutPattern  layout         = NewPatternLayout("%exception{stacktrace}");

            stringAppender.Layout = layout;

            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());

            BasicConfig.Config(rep, stringAppender);

            ILog log1 = LogManager.Get(rep.Name, "TestExceptionPattern");

            Exception exception = new Exception("Oh no!");

            log1.Info("TestMessage", exception);

            Assert.AreEqual(TextDefault.NullText, stringAppender.GetString());

            stringAppender.Reset();
        }
コード例 #7
0
        public void TestAddingCustomPattern()
        {
            StringAppender stringAppender = new StringAppender();
            LayoutPattern  layout         = NewPatternLayout();

            layout.AddConverter("TestAddingCustomPattern", typeof(TestMessagePatternConverter));
            layout.Pattern = "%TestAddingCustomPattern";
            layout.Activate();

            stringAppender.Layout = layout;

            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());

            BasicConfig.Config(rep, stringAppender);

            ILog log1 = LogManager.Get(rep.Name, "TestAddingCustomPattern");

            log1.Info("TestMessage");
            Assert.AreEqual("TestMessage", stringAppender.GetString(), "%TestAddingCustomPattern not registered");
            stringAppender.Reset();
        }
コード例 #8
0
    private IEnumerator AllCharacterLoad() => default;     // 0x008A0DE0-0x008A0E50

    // [IteratorStateMachine] // 0x0061D7E0-0x0061D850
    private IEnumerator CharacterLoad(List <NDConverterSharedData.PokemonStrage> list, LayoutPattern layout, GenderType gender) => default;    // 0x008A0E80-0x008A0F10
コード例 #9
0
        internal void SetActivePattern(LayoutPattern pattern)
        {
            label_1 :
            int num1 = -1582567626;
            object dataLock;

            while (true)
            {
                int  num2 = -554570146;
                uint num3;
                switch ((num3 = (uint)(num1 ^ num2)) % 3U)
                {
                case 1:
                    dataLock = SharedData.dataLock;
                    num1     = (int)num3 * -1619709966 ^ -568713933;
                    continue;

                case 2:
                    goto label_1;

                default:
                    goto label_4;
                }
            }
label_4:
            bool flag = false;

            try
            {
                SharedData.\u206E​​‍‬‮‎‏‫‌‎‎‌‎‏‎​‎‏​‪‮(dataLock, ref flag);
                this.activePattern = pattern;
            }
            finally
            {
                if (flag)
                {
label_7:
                    int num2 = -2040093341;
                    while (true)
                    {
                        int  num3 = -554570146;
                        uint num4;
                        switch ((num4 = (uint)(num2 ^ num3)) % 4U)
                        {
                        case 0:
                            goto label_7;

                        case 1:
                            SharedData.\u206B‫‫‪‭‌‮‏‪‭‭‮‏‌‌‬‍‮‭‪‌​‪‌‏‏‏‍‮(dataLock);
                            num2 = (int)num4 * 980393169 ^ 2039205412;
                            continue;

                        case 3:
                            num2 = (int)num4 * 599136642 ^ -763283174;
                            continue;

                        default:
                            goto label_11;
                        }
                    }
                }
                label_11 :;
            }
        }
コード例 #10
0
 public ZoomLayoutPatternEventArgs(LayoutPattern pattern)
 {
     this.PatternName = pattern.PatternName;
     this.Pattern     = pattern;
 }