* fix: Adjust namespaces

* docs: Update README
This commit is contained in:
Jérôme Laban 2020-12-20 22:56:42 -05:00 коммит произвёл GitHub
Родитель 983093bb50
Коммит ee688be304
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 33 добавлений и 18 удалений

Просмотреть файл

@ -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());
```

Просмотреть файл

@ -4,9 +4,9 @@ using System.Text;
using CoreFoundation;
using Microsoft.Extensions.Logging;
namespace SamplesApp.Logger
namespace Uno.Extensions.Logging
{
internal class OSLogLoggerProvider<T> : ILogger<T>, ILogger
internal class OSLogLogger : ILogger<object>, 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));
}

Просмотреть файл

@ -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
{
/// <summary>
/// A provider of <see cref="WebAssemblyConsoleLogger{T}"/> instances.
/// </summary>
internal class OSLogLoggerProvider : ILoggerProvider
public class OSLogLoggerProvider : ILoggerProvider
{
private readonly ConcurrentDictionary<string, OSLogLoggerProvider<object>> _loggers;
private readonly ConcurrentDictionary<string, OSLogLogger> _loggers;
/// <summary>
/// Creates an instance of <see cref="WebAssemblyConsoleLoggerProvider"/>.
/// </summary>
public OSLogLoggerProvider()
{
_loggers = new ConcurrentDictionary<string, OSLogLoggerProvider<object>>();
_loggers = new ConcurrentDictionary<string, OSLogLogger>();
}
/// <inheritdoc />
public ILogger CreateLogger(string name)
{
return _loggers.GetOrAdd(name, loggerName => new OSLogLoggerProvider<object>(name));
return _loggers.GetOrAdd(name, loggerName => new OSLogLogger(name));
}
/// <inheritdoc />
@ -34,5 +33,4 @@ namespace SamplesApp.Logger
{
}
}
}
#endif
}

Просмотреть файл

@ -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<object>, ILogger
{

Просмотреть файл

@ -5,7 +5,7 @@ using System;
using System.Collections.Concurrent;
using Microsoft.Extensions.Logging;
namespace SamplesApp.Logger
namespace Uno.Extensions.Logging.WebAssembly
{
/// <summary>
/// A provider of <see cref="WebAssemblyConsoleLogger"/> instances.