-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NR use NLog and improve logging and tracking via telemetry
- Loading branch information
Showing
13 changed files
with
132 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
using System.Diagnostics; | ||
using NLog; | ||
|
||
namespace Waf.NewsReader.Applications; | ||
|
||
public static class Log | ||
internal static class Log | ||
{ | ||
public static TraceSource Default { get; } = new TraceSource("App"); | ||
} | ||
public static Logger Default { get; } = LogManager.GetLogger("App"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.AppCenter.Crashes; | ||
using NLog; | ||
|
||
namespace Waf.NewsReader.Applications; | ||
|
||
public static class LogExtensions | ||
{ | ||
public static void TrackError(this Logger log, Exception ex, [Localizable(false)] string message) | ||
{ | ||
log.Error(ex, message); | ||
Crashes.TrackError(ex); | ||
} | ||
|
||
public static void TrackError(this Logger log, Exception ex, [Localizable(false)] string format, params object?[] arguments) | ||
{ | ||
log.Error(ex, format, arguments); | ||
Crashes.TrackError(ex); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using NLog; | ||
|
||
namespace Waf.NewsReader.Domain; | ||
|
||
internal static class Log | ||
{ | ||
public static Logger Default { get; } = LogManager.GetLogger("Dom"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using NLog; | ||
|
||
namespace Waf.NewsReader.MauiSystem; | ||
|
||
internal static class Log | ||
{ | ||
public static Logger Default { get; } = LogManager.GetLogger("Sys"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
[assembly: SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", Justification = "<Pending>", Scope = "type", Target = "~T:Waf.NewsReader.Presentation.Views.FeedItemView")] | ||
| ||
[assembly: SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", Justification = "<Pending>", Scope = "type", Target = "~T:Waf.NewsReader.Presentation.Views.FeedItemView")] | ||
[assembly: SuppressMessage("Security", "CA5350:Do Not Use Weak Cryptographic Algorithms", Justification = "<Pending>", Scope = "member", Target = "~M:Waf.NewsReader.Presentation.Services.DataService.GetHash~System.String")] | ||
[assembly: SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes", Scope = "type", Target = "~T:Waf.NewsReader.Presentation.Services.WebStorageService")] | ||
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "<Pending>", Scope = "type", Target = "~T:Waf.NewsReader.Presentation.App")] | ||
[assembly: SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:Waf.NewsReader.Presentation.App.OnCreated")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using NLog; | ||
|
||
namespace Waf.NewsReader.Presentation; | ||
|
||
internal static class Log | ||
{ | ||
public static Logger Default { get; } = LogManager.GetLogger("Pre"); | ||
} | ||
|
71 changes: 0 additions & 71 deletions
71
src/NewsReader/NewsReader.Presentation/Services/AppTraceListener.cs
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/NewsReader/NewsReader.Presentation/Services/AppTraceTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using NLog; | ||
using NLog.Targets; | ||
|
||
namespace Waf.NewsReader.Presentation.Services; | ||
|
||
internal sealed class AppTraceTarget : TargetWithLayout | ||
Check warning on line 6 in src/NewsReader/NewsReader.Presentation/Services/AppTraceTarget.cs GitHub Actions / iOS
Check warning on line 6 in src/NewsReader/NewsReader.Presentation/Services/AppTraceTarget.cs GitHub Actions / iOS
|
||
{ | ||
protected override void Write(LogEventInfo logEvent) | ||
{ | ||
string message = RenderLogEvent(Layout, logEvent); | ||
#if ANDROID | ||
var x = logEvent.Level; | ||
if (x == LogLevel.Fatal || x == LogLevel.Error) | ||
Android.Util.Log.Error(logEvent.LoggerName, message); | ||
else if (x == LogLevel.Warn) | ||
Android.Util.Log.Warn(logEvent.LoggerName, message); | ||
else if (x == LogLevel.Info) | ||
Android.Util.Log.Info(logEvent.LoggerName, message); | ||
else | ||
Android.Util.Log.Verbose(logEvent.LoggerName, message); | ||
#elif IOS | ||
Console.WriteLine(message); | ||
#else | ||
System.Diagnostics.Trace.WriteLine(message); | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters