Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/SiteMonitor/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
using System;
using System.IO;

using Avalonia;
using Avalonia.ReactiveUI;

using log4net;
using log4net.Config;

namespace SiteMonitor;

internal sealed class Program {
/// <summary>
/// The logger.
/// </summary>
private static readonly ILog LOG = LogManager.GetLogger(typeof(Program));

// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) {
#if DEBUG
XmlConfigurator.Configure(new FileInfo("log4net.debug.config"));
#else
XmlConfigurator.Configure(new FileInfo("log4net.config"));
#endif

LOG.Info("Started application");

AppDomain.CurrentDomain.UnhandledException += (_, exceptArgs) => {
LOG.Fatal("Unhandled exception", exceptArgs.ExceptionObject as Exception);
};

BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
}
Expand Down
7 changes: 4 additions & 3 deletions src/SiteMonitor/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
using System.Linq;
using System.Threading.Tasks;

using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;

using Microsoft.Extensions.DependencyInjection;

using Nullinside.Api.Common.Desktop;
#if !DEBUG
#if !RELEASE
using Avalonia.Threading;

using SiteMonitor.ViewModels;

#else
using Avalonia;

Check failure on line 18 in src/SiteMonitor/Views/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Roslyn Compiler Warnings

The using directive for 'Avalonia' appeared previously in this namespace

Check failure on line 18 in src/SiteMonitor/Views/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Roslyn Compiler Warnings

The using directive for 'Avalonia' appeared previously in this namespace
#endif


Expand Down Expand Up @@ -72,12 +73,12 @@
if (serverVersion.name?.Equals(Constants.APP_VERSION, StringComparison.InvariantCultureIgnoreCase) ?? true) {
// Had to add this because code clean up tools were removing the "redundant" return statement.
// which was causing the check to always be ignored.
#if !DEBUG
#if !RELEASE
return;
#endif
}

#if !DEBUG
#if !RELEASE
var vm = ServiceProvider?.GetRequiredService<NewVersionWindowViewModel>();
if (null == vm) {
return;
Expand Down
24 changes: 24 additions & 0 deletions src/SiteMonitor/log4net.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
</layout>
</appender>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="${AppData}\\nullinside\\twitch-streaming-tools\\log.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="5"/>
<maximumFileSize value="10MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
</layout>
</appender>

<root>
<level value="INFO"/>
<appender-ref ref="ConsoleAppender"/>
<appender-ref ref="FileAppender"/>
</root>
</log4net>
12 changes: 12 additions & 0 deletions src/SiteMonitor/log4net.debug.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
</layout>
</appender>

<root>
<level value="DEBUG"/>
<appender-ref ref="ConsoleAppender"/>
</root>
</log4net>
Loading