using EonaCat.LogStack.Core;
using System;
using System.Runtime.CompilerServices;

namespace EonaCat.LogStack.Boosters
{
    // 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.

    /// <summary>
    /// Adds a custom text property to log events
    /// </summary>
    public sealed class CustomTextBooster : BoosterBase
    {
        private readonly string _propertyName;
        private readonly string _text;

        /// <summary>
        /// Creates a new booster that adds a custom text property to logs
        /// </summary>
        /// <param name="propertyName">The name of the property to add</param>
        /// <param name="text">The text value to set</param>
        public CustomTextBooster(string propertyName, string text)
            : base("CustomText")
        {
            _propertyName = propertyName ?? throw new ArgumentNullException(nameof(propertyName));
            _text = text ?? throw new ArgumentNullException(nameof(text));
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override bool Boost(ref LogEventBuilder builder)
        {
            builder.WithProperty(_propertyName, _text);
            return true;
        }
    }
}
