From 3bd12aa039b24168c4c1e0d024a817801e6e0c98 Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Fri, 25 Oct 2024 12:48:31 -0600 Subject: [PATCH] docs: update docs layout --- docs/plugins/essentials/permissions.md | 62 -------------- .../permissions/permissions-manager.md | 62 ++++++++++++++ docs/plugins/essentials/permissions/toc.yml | 2 + docs/plugins/essentials/toc.yml | 2 +- docs/plugins/logging/index.md | 81 +++---------------- docs/plugins/logging/interop/essentials.md | 6 ++ .../logging/{ => interop}/microsoft.md | 37 ++++++--- docs/plugins/logging/interop/toc.yml | 4 + docs/plugins/logging/providers/appcenter.md | 22 +++++ docs/plugins/logging/providers/console.md | 13 +++ docs/plugins/logging/providers/debug.md | 13 +++ docs/plugins/logging/{ => providers}/gelf.md | 0 .../plugins/logging/{ => providers}/raygun.md | 0 docs/plugins/logging/providers/sentry.md | 11 +++ .../logging/{ => providers}/testing.md | 0 docs/plugins/logging/providers/toc.yml | 14 ++++ docs/plugins/logging/providers/xunit.md | 13 +++ docs/plugins/logging/toc.yml | 12 +-- 18 files changed, 205 insertions(+), 149 deletions(-) delete mode 100644 docs/plugins/essentials/permissions.md create mode 100644 docs/plugins/essentials/permissions/permissions-manager.md create mode 100644 docs/plugins/essentials/permissions/toc.yml create mode 100644 docs/plugins/logging/interop/essentials.md rename docs/plugins/logging/{ => interop}/microsoft.md (72%) create mode 100644 docs/plugins/logging/interop/toc.yml create mode 100644 docs/plugins/logging/providers/appcenter.md create mode 100644 docs/plugins/logging/providers/console.md create mode 100644 docs/plugins/logging/providers/debug.md rename docs/plugins/logging/{ => providers}/gelf.md (100%) rename docs/plugins/logging/{ => providers}/raygun.md (100%) create mode 100644 docs/plugins/logging/providers/sentry.md rename docs/plugins/logging/{ => providers}/testing.md (100%) create mode 100644 docs/plugins/logging/providers/toc.yml create mode 100644 docs/plugins/logging/providers/xunit.md diff --git a/docs/plugins/essentials/permissions.md b/docs/plugins/essentials/permissions.md deleted file mode 100644 index 077acbe..0000000 --- a/docs/plugins/essentials/permissions.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -uid: Plugins.Essentials.Permissions ---- - -# App Permissions - -The Permissions API in Prism.Plugin.Essentials allows you to request and check permissions across Android, iOS, MacCatalyst and WinUI on both .NET MAUI and Uno Platform. As with other API's in Prism.Essentials this is automatically registered when Registering Prism Essentials. - -## Getting Started - -To use the Permissions Manager you can inject the `IPermissionsManager` into your services or ViewModels. - -```cs -public class MyViewModel(IPermissionsManager permissions) : BindableBase -{ -} -``` - -To check the state of a given permission you simply need to pass the permission type to the Permission Manager's Check or Request method like: - -```cs -var status = await permissions.CheckStatusAsync(); - -if (status != PermissionStatus.NotSupported && status != PermissionStatus.Granted) -{ - status = await permissions.RequestAsync(); -} -``` - -A permission status of `NotSupported` may be returned when the underlying platform does not require authorization for a specific permission. - -## Supported Permissions - -| Permission | Android | iOS | MacCatalyst | WinUI | -|------------|:-------:|:---:|:-----------:|:-----:| -| Battery | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Bluetooth | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| CalendarRead | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| CalendarWrite | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Camera | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| ContactsRead | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | -| ContactsWrite | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | -| Flashlight | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| LaunchApp | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| LocationAlways | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | -| LocationWhenInUse | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | -| Maps | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Media | ![Not Supported](../../images/cross_red_circle.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Microphone | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| NearbyWifiDevices | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| NetworkState | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Phone | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Photos | ![Not Supported](../../images/cross_red_circle.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| PhotosAddOnly | ![Not Supported](../../images/cross_red_circle.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| PostNotifications | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Reminders | ![Not Supported](../../images/cross_red_circle.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Sensors | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | -| Sms | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Speech | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | -| StorageRead | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| StorageWrite | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | -| Vibrate | ![Supported](../../images/circle_green_checkmark.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | ![Not Supported](../../images/cross_red_circle.png) | diff --git a/docs/plugins/essentials/permissions/permissions-manager.md b/docs/plugins/essentials/permissions/permissions-manager.md new file mode 100644 index 0000000..bea5176 --- /dev/null +++ b/docs/plugins/essentials/permissions/permissions-manager.md @@ -0,0 +1,62 @@ +--- +uid: Plugins.Essentials.Permissions +--- + +# App Permissions + +The Permissions API in Prism.Plugin.Essentials allows you to request and check permissions across Android, iOS, MacCatalyst and WinUI on both .NET MAUI and Uno Platform. As with other API's in Prism.Essentials this is automatically registered when Registering Prism Essentials. + +## Getting Started + +To use the Permissions Manager you can inject the `IPermissionsManager` into your services or ViewModels. + +```cs +public class MyViewModel(IPermissionsManager permissions) : BindableBase +{ +} +``` + +To check the state of a given permission you simply need to pass the permission type to the Permission Manager's Check or Request method like: + +```cs +var status = await permissions.CheckStatusAsync(); + +if (status != PermissionStatus.NotSupported && status != PermissionStatus.Granted) +{ + status = await permissions.RequestAsync(); +} +``` + +A permission status of `NotSupported` may be returned when the underlying platform does not require authorization for a specific permission. + +## Supported Permissions + +| Permission | Android | iOS | MacCatalyst | WinUI | +|------------|:-------:|:---:|:-----------:|:-----:| +| Battery | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Bluetooth | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| CalendarRead | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| CalendarWrite | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Camera | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| ContactsRead | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | +| ContactsWrite | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | +| Flashlight | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| LaunchApp | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| LocationAlways | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | +| LocationWhenInUse | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | +| Maps | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Media | ![Not Supported](../../../images/cross_red_circle.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Microphone | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| NearbyWifiDevices | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| NetworkState | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Phone | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Photos | ![Not Supported](../../../images/cross_red_circle.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| PhotosAddOnly | ![Not Supported](../../../images/cross_red_circle.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| PostNotifications | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Reminders | ![Not Supported](../../../images/cross_red_circle.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Sensors | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | +| Sms | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Speech | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| StorageRead | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| StorageWrite | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | +| Vibrate | ![Supported](../../../images/circle_green_checkmark.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | ![Not Supported](../../../images/cross_red_circle.png) | diff --git a/docs/plugins/essentials/permissions/toc.yml b/docs/plugins/essentials/permissions/toc.yml new file mode 100644 index 0000000..aa26a7e --- /dev/null +++ b/docs/plugins/essentials/permissions/toc.yml @@ -0,0 +1,2 @@ +- name: Permissions Manager + href: permissions-manager.md \ No newline at end of file diff --git a/docs/plugins/essentials/toc.yml b/docs/plugins/essentials/toc.yml index 82c0829..3f7e564 100644 --- a/docs/plugins/essentials/toc.yml +++ b/docs/plugins/essentials/toc.yml @@ -11,6 +11,6 @@ - name: Notifications href: notifications/toc.yml - name: Permissions - href: permissions.md + href: permissions/toc.yml - name: Threading href: threading/toc.yml \ No newline at end of file diff --git a/docs/plugins/logging/index.md b/docs/plugins/logging/index.md index 904b90e..73ce2fb 100644 --- a/docs/plugins/logging/index.md +++ b/docs/plugins/logging/index.md @@ -119,71 +119,16 @@ In the above example we can see that we have a single Debug log generated which Prism provides a number of logging providers available out of the box for you with additional providers currently under consideration. If we do not have integration for a provider that you would like please let us know on Discord. -### AppCenter - -As previously mentioned, Prism.Plugin.Logging has a couple of interfaces which help users better map to the sort of calls that you might be used to with the AppCenter SDK. This can really help you in 2 critical ways. - -1) By removing the static references to the AppCenter SDK from your codebase, your code becomes easier to manage over time as you have the ability to swap out providers or inject a mock for Unit Testing. -2) Since AppCenter is nearing EOL, it will be critical for businesses to continue using App Center while they evaluate other options. Prism.Plugin.Logging will help you to do just that by combining the AppCenter provider with the AggregateLogger as you evaluate other providers. - -```cs -// By Default this registers Analytics and Crashes -containerRegistry.RegisterAppCenterLogger("appSecret"); - -// If you need to customize the list with other providers -containerRegistry.RegisterAppCenterLogger("appSecret", typeof(Analytics), typeof(Crashes), typeof(Distribution)); -``` - -### Console Logger - -By installing the `Prism.Plugin.Logging.Console` package you get access to the generic Console Logger. This will literally call `System.Console.WriteLine` to write logging messages. - -```cs -containerRegistry.UsePrismLogging(logging => { - logging.AddConsole(); -}); -``` - -### Debug Logger - -Similar to the Console Logger is the Debug Logger. This will use `System.Diagnostics.Debug.WriteLine`, and will only write to `Debug.WriteLine` when the Debugger is currently attached. This is a great logger to use for debugging in your IDE and will not produce any logs in the device console if you forget to remove it for production. - -```cs -containerRegistry.UsePrismLogging(logging => { - logging.AddDebug(); -}); -``` - -### Graylog (GELF) - -For more information see the [Gelf docs](xref:Plugins.Logging.Gelf). - -### Microsoft.Extensions.Logging Interoperability - -For more information see the [Microsoft.Extensions.Logging Interoperability docs](xref:Plugins.Logging.Microsoft). - -### Raygun - -For more information see the [Prism Logging docs for Raygun](xref:Plugins.Logging.Raygun). - -### Sentry - -```cs -containerRegistry.UsePrismLogging(logging => { - logging.AddSentry("sentryDsn"); -}); -``` - -### Testing - -For more information on Unit Testing support see the [Prism.Plugin.Logging.Testing docs](xref:Plugins.Logging.Testing). - -### Xunit - -Unit testing is critical to catching bugs early. But the logging that you might have in your application you probably don't want to have used in your unit tests. For this reason we have an Xunit provider that enables logging using the ITestOutputHelper. This will help to ensure that logs collected during a unit test are associated with the test and makes it easier to view the logged output from your tests. - -```cs -containerRegistry.UsePrismLogging(logging => { - logging.AddXunit(testOutputHelper); -}); -``` +- [AppCenter](xref:Plugins.Logging.AppCenter) +- [Console](xref:Plugins.Logging.Console) +- [Debug](xref:Plugins.Logging.Debug) +- [Graylog (GELF)](xref:Plugins.Logging.Gelf) +- [Raygun](xref:Plugins.Logging.Raygun) +- [Sentry](xref:Plugins.Logging.Sentry) +- [Testing](xref:Plugins.Logging.Testing) +- [Xunit](xref:Plugins.Logging.Xunit) + +## Interop Extensions + +- [Microsoft.Extensions.Logging Interoperability](xref:Plugins.Logging.Microsoft) +- [Prism.Plugins.Essentials](xref:Plugins.Logging.Essentials) diff --git a/docs/plugins/logging/interop/essentials.md b/docs/plugins/logging/interop/essentials.md new file mode 100644 index 0000000..cb4a50f --- /dev/null +++ b/docs/plugins/logging/interop/essentials.md @@ -0,0 +1,6 @@ +--- +uid: Plugins.Logging.Essentials +--- + +# Logging Interop with Prism.Plugin.Essentials + diff --git a/docs/plugins/logging/microsoft.md b/docs/plugins/logging/interop/microsoft.md similarity index 72% rename from docs/plugins/logging/microsoft.md rename to docs/plugins/logging/interop/microsoft.md index cf4a3f4..86c3aa1 100644 --- a/docs/plugins/logging/microsoft.md +++ b/docs/plugins/logging/interop/microsoft.md @@ -6,28 +6,45 @@ uid: Plugins.Logging.Microsoft We recognize that your apps (particularly .NET MAUI and Uno Platform), may have logging that occurs internally using Microsoft.Extensions.Logging. For this reason we've taken the time to put together a logging adapter that allows the logging output from the Microsoft.Extensions.Logging.ILogger to be passed through to the configured Prism Logging Providers that you have in your application. While the exact code may vary -## Prism for Uno Platform +## [.NET MAUI](#tab/maui) + +You can use the Prism App Builder ```cs -public class App : PrismApplication +public static class PrismStartup { - protected override void ConfigureHost(IHostBuilder hostBuilder) + public static void Configure(PrismAppBuilder builder) { - builder.UseLogging(configure: (context, logBuilder) => { - logBuilder.AddPrismLogging(); - }); + builder.ConfigureLogging(logging => logging.AddPrismLogging()); } } ``` -## Prism for .NET MAUI +Or alternatively you may also use the MAUI App Builder ```cs -public static class PrismStartup +public static class MauiProgram { - public static void Configure(PrismAppBuilder builder) + public static MauiApp CreateMauiApp() { - builder.ConfigureLogging(logging => logging.AddPrismLogging()); + var builder = MauiApp.CreateBuilder(); + builder.Logging.AddPrismLogging(); } } ``` + +## [Uno Platform](#tab/uno-platform) + +```cs +public class App : PrismApplication +{ + protected override void ConfigureHost(IHostBuilder hostBuilder) + { + builder.UseLogging(configure: (context, logBuilder) => { + logBuilder.AddPrismLogging(); + }); + } +} +``` + +--- diff --git a/docs/plugins/logging/interop/toc.yml b/docs/plugins/logging/interop/toc.yml new file mode 100644 index 0000000..bc02f28 --- /dev/null +++ b/docs/plugins/logging/interop/toc.yml @@ -0,0 +1,4 @@ +- name: Essentials + href: essentials.md +- name: Microsoft Extensions + href: microsoft.md \ No newline at end of file diff --git a/docs/plugins/logging/providers/appcenter.md b/docs/plugins/logging/providers/appcenter.md new file mode 100644 index 0000000..69e6383 --- /dev/null +++ b/docs/plugins/logging/providers/appcenter.md @@ -0,0 +1,22 @@ +--- +uid: Plugins.Logging.AppCenter +--- + +# AppCenter + +While AppCenter has been deprecated and will be officially shut down in March of 2025 many apps continue to have a dependency on AppCenter. As a result Prism Logging will continue to ship the AppCenter package until it has been officially retired. + +As previously mentioned, Prism.Plugin.Logging has a couple of interfaces which help users better map to the sort of calls that you might be used to with the AppCenter SDK. This can really help you in 2 critical ways. + +1) By removing the static references to the AppCenter SDK from your codebase, your code becomes easier to manage over time as you have the ability to swap out providers or inject a mock for Unit Testing. +2) Since AppCenter is nearing EOL, it will be critical for businesses to continue using App Center while they evaluate other options. Prism.Plugin.Logging will help you to do just that by combining the AppCenter provider with the AggregateLogger as you evaluate other providers. + +```cs +containerRegistry.UsePrismLogging(logging => { + // By Default this registers Analytics and Crashes + logging.UseAppCenter("appSecret"); + + // If you need to customize the list with other providers + logging.UseAppCenter("appSecret", typeof(Analytics), typeof(Crashes), typeof(Distribution)); +}); +``` diff --git a/docs/plugins/logging/providers/console.md b/docs/plugins/logging/providers/console.md new file mode 100644 index 0000000..30be254 --- /dev/null +++ b/docs/plugins/logging/providers/console.md @@ -0,0 +1,13 @@ +--- +uid: Plugins.Logging.Console +--- + +# Console + +By installing the `Prism.Plugin.Logging.Console` package you get access to the generic Console Logger. This will literally call `System.Console.WriteLine` to write logging messages. + +```cs +containerRegistry.UsePrismLogging(logging => { + logging.AddConsole(); +}); +``` diff --git a/docs/plugins/logging/providers/debug.md b/docs/plugins/logging/providers/debug.md new file mode 100644 index 0000000..e00cf3a --- /dev/null +++ b/docs/plugins/logging/providers/debug.md @@ -0,0 +1,13 @@ +--- +uid: Plugins.Logging.Debug +--- + +# Debug + +Similar to the Console Logger is the Debug Logger. This will use `System.Diagnostics.Debug.WriteLine`, and will only write to `Debug.WriteLine` when the Debugger is currently attached. This is a great logger to use for debugging in your IDE and will not produce any logs in the device console if you forget to remove it for production. + +```cs +containerRegistry.UsePrismLogging(logging => { + logging.AddDebug(); +}); +``` diff --git a/docs/plugins/logging/gelf.md b/docs/plugins/logging/providers/gelf.md similarity index 100% rename from docs/plugins/logging/gelf.md rename to docs/plugins/logging/providers/gelf.md diff --git a/docs/plugins/logging/raygun.md b/docs/plugins/logging/providers/raygun.md similarity index 100% rename from docs/plugins/logging/raygun.md rename to docs/plugins/logging/providers/raygun.md diff --git a/docs/plugins/logging/providers/sentry.md b/docs/plugins/logging/providers/sentry.md new file mode 100644 index 0000000..3094fe7 --- /dev/null +++ b/docs/plugins/logging/providers/sentry.md @@ -0,0 +1,11 @@ +--- +uid: Plugins.Logging.Sentry +--- + +# Sentry + +```cs +containerRegistry.UsePrismLogging(logging => { + logging.AddSentry("sentryDsn"); +}); +``` diff --git a/docs/plugins/logging/testing.md b/docs/plugins/logging/providers/testing.md similarity index 100% rename from docs/plugins/logging/testing.md rename to docs/plugins/logging/providers/testing.md diff --git a/docs/plugins/logging/providers/toc.yml b/docs/plugins/logging/providers/toc.yml new file mode 100644 index 0000000..569af85 --- /dev/null +++ b/docs/plugins/logging/providers/toc.yml @@ -0,0 +1,14 @@ +- name: AppCenter + href: appcenter.md +- name: Console + href: console.md +- name: Debug + href: debug.md +- name: Graylog + href: gelf.md +- name: Raygun + href: raygun.md +- name: Unit Testing + href: testing.md +- name: Xunit + href: xunit.md \ No newline at end of file diff --git a/docs/plugins/logging/providers/xunit.md b/docs/plugins/logging/providers/xunit.md new file mode 100644 index 0000000..0900cb7 --- /dev/null +++ b/docs/plugins/logging/providers/xunit.md @@ -0,0 +1,13 @@ +--- +uid: Plugins.Logging.Xunit +--- + +# Xunit + +Unit testing is critical to catching bugs early. But the logging that you might have in your application you probably don't want to have used in your unit tests. For this reason we have an Xunit provider that enables logging using the ITestOutputHelper. This will help to ensure that logs collected during a unit test are associated with the test and makes it easier to view the logged output from your tests. + +```cs +containerRegistry.UsePrismLogging(logging => { + logging.AddXunit(testOutputHelper); +}); +``` diff --git a/docs/plugins/logging/toc.yml b/docs/plugins/logging/toc.yml index 79dbbf3..0263a98 100644 --- a/docs/plugins/logging/toc.yml +++ b/docs/plugins/logging/toc.yml @@ -1,10 +1,6 @@ - name: Getting Started href: index.md -- name: Graylog - href: gelf.md -- name: Microsoft Extensions - href: microsoft.md -- name: Raygun - href: raygun.md -- name: Unit Testing - href: testing.md \ No newline at end of file +- name: Interop + href: interop/toc.yml +- name: Providers + href: providers/toc.yml \ No newline at end of file