コード例 #1
0
ファイル: LoggerTests.cs プロジェクト: Tahvohck/Modnix
        [TestMethod()] public void MultipleFilters()
        {
            var Logger  = new LoggerProxy(Log);
            var filters = Logger.Filters;

            filters.Add(LogFilters.AddPrefix("Pre>"));

            Log.WriteDelay = 0;
            Log.Filters.Add(LogFilters.IgnoreDuplicateExceptions());
            Log.Filters.Add(LogFilters.AutoMultiParam);
            Log.Filters.Add(LogFilters.FormatParams);
            Log.Filters.Add(LogFilters.ResolveLazy);
            Log.Filters.Add(LogFilters.AddPostfix("<Post"));

            Logger.Info("ARST");
            Assert.IsTrue(LogContent.Contains("Pre>ARST"), "Simple Log");

            Logger.Info("A", "R", null, "S", "T");
            Assert.IsTrue(LogContent.Contains(">A R null S T<"), "Format multi params");

            Logger.Info((Func <string>)(() => "QWFP"));
            Assert.IsTrue(LogContent.Contains(">QWFP"), "Resolve lazy");

            Exception subject = new Exception();

            Logger.Error(subject);
            Assert.IsTrue(LogContent.Contains("Pre>System.Exception:"), "Exception is logged");
            var len = LogSize;

            Logger.Error("Error: {0}", subject);
            Assert.IsTrue(LogSize == len, "Duplicate is suppressed");
        }
コード例 #2
0
            }             // ctor

            public void Log(LoggerProxy log, string firstLine)
            {
                // logging
                log.Info(String.Join(Environment.NewLine,
                                     firstLine,
                                     "  Filename: {0}",
                                     "  Originator: {1}",
                                     "  VirtualFileName: {2}",
                                     "  Stamp: {3:F}",
                                     "  Format: {4}",
                                     "  MaximumRecordSize: {5:N0}",
                                     "  FileSize: {6:N0}",
                                     "  FileSizeUnpacked: {7:N0}",
                                     "  Description: {8}"
                                     ),
                         fileInfo.Name,
                         sourceOrDestination,
                         virtualFileName,
                         fileStamp,
                         format,
                         maximumRecordSize,
                         fileSize,
                         fileSizeUnpacked,
                         description
                         );
            }             // proc Log
コード例 #3
0
            public FileServiceSession(DirectoryFileServiceItem service, int sessionId)
            {
                this.sessionId = sessionId;
                this.service   = service;
                this.log       = LoggerProxy.Create(service.Log, sessionId.ToString());

                log.Info("Session started...");
                service.OnSessionStart();
            }             // ctor
コード例 #4
0
            protected LuaScript(LuaEngine engine, string scriptId, bool compileWithDebugger)
            {
                this.engine   = engine;
                this.log      = LoggerProxy.Create(engine.Log, scriptId);
                this.scriptId = scriptId;

                this.chunk = null;
                this.compiledWithDebugger = compileWithDebugger;

                // attach the script to the engine
                engine.AddScript(this);

                log.Info("Hinzugefügt.");
            }             // ctor
コード例 #5
0
            }             // proc Dispose

            protected virtual void Dispose(bool disposing)
            {
                if (disposing)
                {
                    foreach (var g in engine.GetAttachedGlobals(scriptId))
                    {
                        g.ResetScript();
                    }

                    // Remove the script from the engine
                    engine.RemoveScript(this);
                    log.Info("Entfernt.");

                    Procs.FreeAndNil(ref chunk);
                }
            }             // proc Dispose
コード例 #6
0
            }             // func GetScript

            public void OnScriptChanged()
            {
                var e = new CancelEventArgs(!autoRun);

                if (ScriptChanged != null)
                {
                    ScriptChanged(this, e);
                }

                if (e.Cancel || !IsCompiled)
                {
                    needToRun = true;
                    log.Info("Waiting for execution.");
                }
                else
                {
                    Run(false);
                }
            }             // proc OnScriptChanged
コード例 #7
0
ファイル: LoggerTests.cs プロジェクト: Tahvohck/Modnix
        [TestMethod()] public void LoggerProxy()
        {
            Log.WriteDelay = 1000;
            var         Log2  = new FileLogger("logtest2.tmp", 1000);
            LoggerProxy proxy = new LoggerProxy(true, Log);

            proxy.Masters.Add(Log2);

            proxy.Info("Proxy");
            proxy.Flush();
            Assert.IsTrue(LogContent.Contains("Proxy"), "Proxy is forwarding to 1st log");
            Assert.IsTrue(File.ReadAllText(Log2.LogFile).Contains("Proxy"), "Proxy is forwarding to 2nd log");

            proxy.Clear();
            Assert.IsFalse(File.Exists(Log.LogFile), "Proxy is clearing 1st Log");
            Assert.IsFalse(File.Exists(Log2.LogFile), "Proxy is clearing 2nd Log");

            Log2.Level  = System.Diagnostics.SourceLevels.Verbose;
            proxy.Level = System.Diagnostics.SourceLevels.Information;
            proxy.Verbo("Verbose filtered");
            proxy.Flush();
            Assert.IsFalse(File.Exists(Log.LogFile), "Proxy is not forwarding low levels");
            Assert.IsFalse(File.Exists(Log2.LogFile), "Proxy is not forwarding low levels 2");

            proxy.Level = System.Diagnostics.SourceLevels.Verbose;
            proxy.Verbo("Verbose written");
            proxy.Flush();
            Assert.IsFalse(File.Exists(Log.LogFile), "Proxy is not writing to low levels");
            Assert.IsTrue(File.Exists(Log2.LogFile), "Proxy is writing to low levels 2");
            proxy.Clear();

            try {
                new LoggerProxy(false).Clear();
                Assert.IsTrue(false, "Proxy failed to disallow clear");
            } catch (InvalidOperationException) {
                Assert.IsTrue(true, "Proxy may disallow clear");
            }

            Assert.AreEqual(null, Error, "OnError");
        }
コード例 #8
0
            }             // proc SendAnswerAsync

            private void Info(string message)
            => log.Info(message);
コード例 #9
0
            }             // ctor

            public void Dispose()
            {
                service.OnSessionClosed();
                log.Info("Session finished...");
            }             // proc Dispose
コード例 #10
0
ファイル: DirectoryFileService.cs プロジェクト: twdes/odette
			public FileServiceSession(DirectoryFileServiceItem service, int sessionId)
			{
				this.sessionId = sessionId;
				this.service = service;
				this.log = LoggerProxy.Create(service.Log, sessionId.ToString());

				log.Info("Session started...");
				service.OnSessionStart();
			} // ctor
コード例 #11
0
ファイル: DirectoryFileService.cs プロジェクト: twdes/odette
			} // ctor

			public void Log(LoggerProxy log, string firstLine)
			{
				// logging
				log.Info(String.Join(Environment.NewLine,
						firstLine,
						"  Filename: {0}",
						"  Originator: {1}",
						"  VirtualFileName: {2}",
						"  Stamp: {3:F}",
						"  Format: {4}",
						"  MaximumRecordSize: {5:N0}",
						"  FileSize: {6:N0}",
						"  FileSizeUnpacked: {7:N0}",
						"  Description: {8}"
					),
					fileInfo.Name,
					originator,
					virtualFileName,
					fileStamp,
					format,
					maximumRecordSize,
					fileSize,
					fileSizeUnpacked,
					description
				);
			} // proc Log
コード例 #12
0
ファイル: DynamicPowerShell.cs プロジェクト: twdes/powershell
 public override void NotifyBeginApplication()
 => log.Info("Begin of application");