namespace YVR.Utilities
{
    /// <summary>
    /// Base class for all log prefix
    /// </summary>
    public abstract class LogPrefixBase
    {
        private LogPrefixBase m_WrappedLogPrefix = null;

        /// <summary>
        /// Constructor for log prefix
        /// </summary>
        /// <param name="wrappedLogPrefix"> The wrapped log prefix </param>
        protected LogPrefixBase(LogPrefixBase wrappedLogPrefix = null) { m_WrappedLogPrefix = wrappedLogPrefix; }

        /// <summary>
        /// Get prefix which combined wrapped log prefix result and current log prefix result
        /// </summary>
        /// <param name="context"> The context where output the log </param>
        /// <param name="log"> The log message </param>
        /// <param name="priority"> Log Priority </param>
        /// <returns> Combined prefix result </returns>
        public virtual string GetCombinedPrefix(object context, string log, LogPriority priority)
        {
            string wrappedPrefix = m_WrappedLogPrefix == null
                ? string.Empty
                : $"{m_WrappedLogPrefix.GetCombinedPrefix(context, log, priority)} ";

            return $"{wrappedPrefix}{GetPrefix(context, log, priority)}";
        }

        /// <summary>
        /// Function to get prefix
        /// </summary>
        /// <param name="context"> The context where output the log </param>
        /// <param name="log"> The log message </param>
        /// <param name="priority"> Log Priority </param>
        /// <returns>The result generated by this prefix</returns>
        protected abstract string GetPrefix(object context, string log, LogPriority priority);
    }
}