public void When_generating_system_and_networking_report()
        {
            var flags  = DiagnosticReportType.System | DiagnosticReportType.Networking;
            var report = DiagnosticReport.Generate(flags);

            report.ShouldNotBeNull();
            report.Length.ShouldBeGreaterThan(100);

            report.ShouldStartWith("/\r\n|Diagnostic Report generated at:");
            report.ShouldContain("\r\n|\r\n|System|...");
            report.ShouldNotContain("\r\n|\r\n|Process|...");
            report.ShouldNotContain("\r\n|\r\n|Drives|...");
            report.ShouldNotContain("\r\n|\r\n|Assemblies|...");
            report.ShouldContain("\r\n|\r\n|Networking|...");
            report.ShouldContain("|\r\n|\t. Windows IP Configuration\r\n|");
            report.ShouldEndWith("\\");
        }
        public void When_generating_full_report_with_flag()
        {
            // ReSharper disable once RedundantArgumentDefaultValue
            var report = DiagnosticReport.Generate(DiagnosticReportType.Full);

            report.ShouldNotBeNull();
            report.Length.ShouldBeGreaterThan(1000);

            report.ShouldStartWith("/\r\n|Diagnostic Report generated at:");
            report.ShouldContain("\r\n|\r\n|System|...");
            report.ShouldContain("\r\n|\r\n|Process|...");
            report.ShouldContain("\r\n|\r\n|Drives|...");
            report.ShouldContain("\r\n|\r\n|Assemblies|...");
            report.ShouldContain("\r\n|\r\n|Networking|...");
            report.ShouldContain("|\r\n|\t. Windows IP Configuration\r\n|");
            report.ShouldEndWith("\\");
        }
Example #3
0
        public static void Main()
        {
            Log.Logger = new LoggerConfiguration()
                         .Enrich.WithThreadId()
                         .Enrich.WithExceptionDetails()
                         .Enrich.WithDemystifiedStackTraces()
                         .WriteTo.Console(outputTemplate: LOGGER_TEMPLATE)
                         .WriteTo.File("C:/ProgramData/youtube-sync.txt", outputTemplate: LOGGER_TEMPLATE, shared: true)
                         .CreateLogger();

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            var diagnostics = DiagnosticReport.Generate(DiagnosticReportType.Process | DiagnosticReportType.System);

            Log.Information(diagnostics.ToString());

            // Start TopShelf
            HostFactory.Run(hostConfig =>
            {
                hostConfig.Service <YoutubeSyncService>(s =>
                {
                    s.ConstructUsing(name => new YoutubeSyncService());
                    s.WhenStarted(ys => ys.Start());
                    s.WhenStopped(ys => ys.Stop());
                });

                hostConfig.EnableServiceRecovery(rc => rc.RestartService(1));
                hostConfig.EnableSessionChanged();
                hostConfig.UseSerilog();
                hostConfig.RunAsLocalSystem();
                hostConfig.StartAutomatically();

                hostConfig.SetDescription("This service synchronizes youtube play-lists with filesystem");
                hostConfig.SetDisplayName("rEv-soft Youtube Sync");
                hostConfig.SetServiceName("rEv-soft Youtube Sync");

                hostConfig.AddCommandLineSwitch("squirrel", x => StopMyself("Stopping because of squirrel parameter specified"));
                hostConfig.AddCommandLineDefinition("firstrun", x => StopMyself("Stopping because of firstrun parameter specified"));
            });
        }
 public IActionResult Get([FromQuery, Required] string key)
 {
     return(_applicationConfiguration.Key != key
         ? (IActionResult)Unauthorized()
         : Content(DiagnosticReport.Generate().ToString()));
 }