using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;

// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.

namespace EonaCat.Logger.EonaCatCoreLogger.Extensions
{
    /// <summary>
    ///     Extensions for adding the built-in Console Logger to the <see cref="ILoggingBuilder" />
    /// </summary>
    public static class ConsoleLoggerFactoryExtensions
    {
        /// <summary>
        ///     Adds the built-in Console Logger to the logging builder.
        /// </summary>
        /// <param name="builder">The <see cref="ILoggingBuilder" /> to use.</param>
        /// <param name="configure">Optional configuration for <see cref="ConsoleLoggerOptions" /></param>
        public static ILoggingBuilder AddEonaCatConsoleLogger(this ILoggingBuilder builder, Action<ConsoleLoggerOptions> configure = null)
        {
            if (configure != null)
            {
                builder.AddConsole(configure);
            }
            else
            {
                builder.AddConsole();
            }

            return builder;
        }
    }
}
