diff --git a/README.md b/README.md index bcf37f2..a35b794 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ -# template -template for brand new github repositories +# Uno.Extensions.Logging + +A set of logging extensions for `Microsoft.Extensions.Logging`. + +## OSLogLoggerProvider +This logger is using the `OSLog` iOS API to log to the system log. + +Usage example: +```csharp +.AddProvider(new Uno.Extensions.Logging.OSLogLoggerProvider()); +``` + +## WebAssemblyConsoleLoggerProvider +This logger is using the browser's console javascript API + +Usage example: +```csharp +.AddProvider(new Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider()); +``` \ No newline at end of file diff --git a/src/Uno.Extensions.Logging.OSLog/OSLogLogger.cs b/src/Uno.Extensions.Logging.OSLog/OSLogLogger.cs index a547967..4695e32 100644 --- a/src/Uno.Extensions.Logging.OSLog/OSLogLogger.cs +++ b/src/Uno.Extensions.Logging.OSLog/OSLogLogger.cs @@ -4,9 +4,9 @@ using System.Text; using CoreFoundation; using Microsoft.Extensions.Logging; -namespace SamplesApp.Logger +namespace Uno.Extensions.Logging { - internal class OSLogLoggerProvider : ILogger, ILogger + internal class OSLogLogger : ILogger, ILogger { private static readonly string _loglevelPadding = ": "; private static readonly string _messagePadding; @@ -15,19 +15,19 @@ namespace SamplesApp.Logger private readonly string _name; - static OSLogLoggerProvider() + static OSLogLogger() { var logLevelString = GetLogLevelString(LogLevel.Information); _messagePadding = new string(' ', logLevelString.Length + _loglevelPadding.Length); _newLineWithMessagePadding = Environment.NewLine + _messagePadding; } - public OSLogLoggerProvider() + public OSLogLogger() : this(string.Empty) { } - public OSLogLoggerProvider(string name) + public OSLogLogger(string name) { _name = name ?? throw new ArgumentNullException(nameof(name)); } diff --git a/src/Uno.Extensions.Logging.OSLog/OSLogLoggerProvider.cs b/src/Uno.Extensions.Logging.OSLog/OSLogLoggerProvider.cs index 5135899..349b506 100644 --- a/src/Uno.Extensions.Logging.OSLog/OSLogLoggerProvider.cs +++ b/src/Uno.Extensions.Logging.OSLog/OSLogLoggerProvider.cs @@ -1,32 +1,31 @@ -#if __IOS__ || __MACOS__ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; using Microsoft.Extensions.Logging; -namespace SamplesApp.Logger +namespace Uno.Extensions.Logging { /// /// A provider of instances. /// - internal class OSLogLoggerProvider : ILoggerProvider + public class OSLogLoggerProvider : ILoggerProvider { - private readonly ConcurrentDictionary> _loggers; + private readonly ConcurrentDictionary _loggers; /// /// Creates an instance of . /// public OSLogLoggerProvider() { - _loggers = new ConcurrentDictionary>(); + _loggers = new ConcurrentDictionary(); } /// public ILogger CreateLogger(string name) { - return _loggers.GetOrAdd(name, loggerName => new OSLogLoggerProvider(name)); + return _loggers.GetOrAdd(name, loggerName => new OSLogLogger(name)); } /// @@ -34,5 +33,4 @@ namespace SamplesApp.Logger { } } -} -#endif +} \ No newline at end of file diff --git a/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLogger.cs b/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLogger.cs index 33a76a3..9416d35 100644 --- a/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLogger.cs +++ b/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLogger.cs @@ -8,7 +8,7 @@ using System.Text; using Microsoft.Extensions.Logging; using Uno.Foundation; -namespace SamplesApp.Logger +namespace Uno.Extensions.Logging.WebAssembly { internal class WebAssemblyConsoleLogger : ILogger, ILogger { diff --git a/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLoggerProvider.cs b/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLoggerProvider.cs index 091109e..64f708a 100644 --- a/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLoggerProvider.cs +++ b/src/Uno.Extensions.Logging.WebAssembly.Console/WebAssemblyConsoleLoggerProvider.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Concurrent; using Microsoft.Extensions.Logging; -namespace SamplesApp.Logger +namespace Uno.Extensions.Logging.WebAssembly { /// /// A provider of instances.