Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Obsolete old APIs #605

Merged
merged 1 commit into from
May 3, 2017
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ public interface ILoggerFactory : IDisposable
ILogger CreateLogger(string categoryName);

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddProvider() method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds an <see cref="ILoggerProvider"/> to the logging system.
/// </summary>
/// <param name="provider">The <see cref="ILoggerProvider"/>.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddProvider() method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
void AddProvider(ILoggerProvider provider);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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 Microsoft.Extensions.Logging.AzureAppServices;
using Microsoft.Extensions.Logging.AzureAppServices.Internal;

Expand Down Expand Up @@ -36,19 +37,27 @@ public static LoggerFactory AddAzureWebAppDiagnostics(this LoggerFactory factory
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddAzureWebAppDiagnostics() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds an Azure Web Apps diagnostics logger.
/// </summary>
/// <param name="factory">The extension method argument</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddAzureWebAppDiagnostics() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddAzureWebAppDiagnostics(this ILoggerFactory factory)
{
return AddAzureWebAppDiagnostics(factory, new AzureAppServicesDiagnosticsSettings());
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddAzureWebAppDiagnostics() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds an Azure Web Apps diagnostics logger.
/// </summary>
/// <param name="factory">The extension method argument</param>
/// <param name="settings">The setting object to configure loggers.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddAzureWebAppDiagnostics() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddAzureWebAppDiagnostics(this ILoggerFactory factory, AzureAppServicesDiagnosticsSettings settings)
{
if (WebAppContext.Default.IsRunningInAzureWebApp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,70 @@ namespace Microsoft.Extensions.Logging
public static class ConsoleLoggerExtensions
{
/// <summary>
/// Adds a console logger.
/// Adds a console logger named 'Console' to the factory.
/// </summary>
/// <param name="factory">The <see cref="LoggerFactory"/> to use.</param>
public static LoggerFactory AddConsole(this LoggerFactory factory)
{
factory.AddProvider("Console", new ConsoleLoggerProvider(factory.Configuration));
return factory;
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a console logger that is enabled for <see cref="LogLevel"/>.Information or higher.
/// </summary>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(this ILoggerFactory factory)
{
return factory.AddConsole(includeScopes: false);
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a console logger that is enabled for <see cref="LogLevel"/>.Information or higher.
/// </summary>
/// <param name="factory"></param>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
/// <param name="includeScopes">A value which indicates whether log scope information should be displayed
/// in the output.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(this ILoggerFactory factory, bool includeScopes)
{
factory.AddConsole((n, l) => l >= LogLevel.Information, includeScopes);
return factory;
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a console logger that is enabled for <see cref="LogLevel"/>s of minLevel or higher.
/// </summary>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
/// <param name="minLevel">The minimum <see cref="LogLevel"/> to be logged</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(this ILoggerFactory factory, LogLevel minLevel)
{
factory.AddConsole(minLevel, includeScopes: false);
return factory;
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a console logger that is enabled for <see cref="LogLevel"/>s of minLevel or higher.
/// </summary>
/// <param name="factory"></param>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
/// <param name="minLevel">The minimum <see cref="LogLevel"/> to be logged</param>
/// <param name="includeScopes">A value which indicates whether log scope information should be displayed
/// in the output.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(
this ILoggerFactory factory,
LogLevel minLevel,
Expand All @@ -66,10 +84,14 @@ public static ILoggerFactory AddConsole(
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a console logger that is enabled as defined by the filter function.
/// </summary>
/// <param name="factory"></param>
/// <param name="filter"></param>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
/// <param name="filter">The category filter to apply to logs.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(
this ILoggerFactory factory,
Func<string, LogLevel, bool> filter)
Expand All @@ -79,12 +101,16 @@ public static ILoggerFactory AddConsole(
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a console logger that is enabled as defined by the filter function.
/// </summary>
/// <param name="factory"></param>
/// <param name="filter"></param>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
/// <param name="filter">The category filter to apply to logs.</param>
/// <param name="includeScopes">A value which indicates whether log scope information should be displayed
/// in the output.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(
this ILoggerFactory factory,
Func<string, LogLevel, bool> filter,
Expand All @@ -94,6 +120,16 @@ public static ILoggerFactory AddConsole(
return factory;
}


/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// </summary>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
/// <param name="settings">The settings to apply to created <see cref="ConsoleLogger"/>'s.</param>
/// <returns></returns>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(
this ILoggerFactory factory,
IConsoleLoggerSettings settings)
Expand All @@ -102,6 +138,15 @@ public static ILoggerFactory AddConsole(
return factory;
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// </summary>
/// <param name="factory">The <see cref="ILoggerFactory"/> to use.</param>
/// <param name="configuration">The <see cref="IConfiguration"/> to use for <see cref="IConsoleLoggerSettings"/>.</param>
/// <returns></returns>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddConsole() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddConsole(this ILoggerFactory factory, IConfiguration configuration)
{
var settings = new ConfigurationConsoleLoggerSettings(configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ConsoleLoggerProvider : ILoggerProvider
private static readonly Func<string, LogLevel, bool> trueFilter = (cat, level) => true;
private static readonly Func<string, LogLevel, bool> falseFilter = (cat, level) => false;

[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider(IConfiguration).")]
public ConsoleLoggerProvider(Func<string, LogLevel, bool> filter, bool includeScopes)
{
if (filter == null)
Expand Down Expand Up @@ -56,6 +57,7 @@ public ConsoleLoggerProvider(IConfiguration configuration)
_isLegacy = false;
}

[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider(IConfiguration).")]
public ConsoleLoggerProvider(IConsoleLoggerSettings settings)
{
if (settings == null)
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.Extensions.Logging.Debug/DebugLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ public partial class DebugLogger : ILogger
/// </summary>
/// <param name="name">The name of the logger.</param>
public DebugLogger(string name)
#pragma warning disable CS0618 // Type or member is obsolete
: this(name, filter: null)
#pragma warning restore CS0618 // Type or member is obsolete
{
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Logging.Debug.DebugLogger(string).
/// </para>
/// Initializes a new instance of the <see cref="DebugLogger"/> class.
/// </summary>
/// <param name="name">The name of the logger.</param>
/// <param name="filter">The function used to filter events based on the log level.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Logging.Debug.DebugLogger(string).")]
public DebugLogger(string name, Func<string, LogLevel, bool> filter)
{
_name = string.IsNullOrEmpty(name) ? nameof(DebugLogger) : name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Logging
public static class DebugLoggerFactoryExtensions
{
/// <summary>
/// Adds a debug logger.
/// Adds a debug logger named 'Debug' to the factory.
/// </summary>
/// <param name="factory">The extension method argument.</param>
public static LoggerFactory AddDebug(this LoggerFactory factory)
Expand All @@ -22,30 +22,42 @@ public static LoggerFactory AddDebug(this LoggerFactory factory)
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddDebug() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a debug logger that is enabled for <see cref="LogLevel"/>.Information or higher.
/// </summary>
/// <param name="factory">The extension method argument.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddDebug() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddDebug(this ILoggerFactory factory)
{
return AddDebug(factory, LogLevel.Information);
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddDebug() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a debug logger that is enabled as defined by the filter function.
/// </summary>
/// <param name="factory">The extension method argument.</param>
/// <param name="filter">The function used to filter events based on the log level.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddDebug() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddDebug(this ILoggerFactory factory, Func<string, LogLevel, bool> filter)
{
factory.AddProvider(new DebugLoggerProvider(filter));
return factory;
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddDebug() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.
/// </para>
/// Adds a debug logger that is enabled for <see cref="LogLevel"/>s of minLevel or higher.
/// </summary>
/// <param name="factory">The extension method argument.</param>
/// <param name="minLevel">The minimum <see cref="LogLevel"/> to be logged</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is to call the Microsoft.Extensions.Logging.AddDebug() extension method on the Microsoft.Extensions.Logging.LoggerFactory instance.")]
public static ILoggerFactory AddDebug(this ILoggerFactory factory, LogLevel minLevel)
{
return AddDebug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ public class DebugLoggerProvider : ILoggerProvider

public DebugLoggerProvider()
{
_filter = (s, l) => true;
_filter = null;
}

/// <summary>
/// <para>
/// This method is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Logging.Debug.DebugLoggerProvider().
/// </para>
/// Initializes a new instance of the <see cref="DebugLoggerProvider"/> class.
/// </summary>
/// <param name="filter">The function used to filter events based on the log level.</param>
[Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Logging.Debug.DebugLoggerProvider().")]
public DebugLoggerProvider(Func<string, LogLevel, bool> filter)
{
_filter = filter;
Expand All @@ -29,7 +33,9 @@ public DebugLoggerProvider(Func<string, LogLevel, bool> filter)
/// <inheritdoc />
public ILogger CreateLogger(string name)
{
#pragma warning disable CS0618 // Type or member is obsolete
return new DebugLogger(name, _filter);
#pragma warning restore CS0618 // Type or member is obsolete
}

public void Dispose()
Expand Down
Loading