using System;
using NT8.Core.Logging;

namespace NT8.Adapters.NinjaTrader
{
    /// <summary>
    /// Logging adapter for integrating with NT8's logging system
    /// </summary>
    public class NT8LoggingAdapter : ILogger
    {
        /// <summary>
        /// Log debug message
        /// </summary>
        public void LogDebug(string message, params object[] args)
        {
            // In a real implementation, this would call NT8's logging system
            // For now, we'll just use Console.WriteLine as a placeholder
            Console.WriteLine("[DEBUG] " + FormatMessage(message, args));
        }

        /// <summary>
        /// Log information message
        /// </summary>
        public void LogInformation(string message, params object[] args)
        {
            // In a real implementation, this would call NT8's logging system
            Console.WriteLine("[INFO] " + FormatMessage(message, args));
        }

        /// <summary>
        /// Log warning message
        /// </summary>
        public void LogWarning(string message, params object[] args)
        {
            // In a real implementation, this would call NT8's logging system
            Console.WriteLine("[WARN] " + FormatMessage(message, args));
        }

        /// <summary>
        /// Log error message
        /// </summary>
        public void LogError(string message, params object[] args)
        {
            // In a real implementation, this would call NT8's logging system
            Console.WriteLine("[ERROR] " + FormatMessage(message, args));
        }

        /// <summary>
        /// Log critical message
        /// </summary>
        public void LogCritical(string message, params object[] args)
        {
            // In a real implementation, this would call NT8's logging system
            Console.WriteLine("[CRITICAL] " + FormatMessage(message, args));
        }

        /// <summary>
        /// Log error with exception
        /// </summary>
        public void LogError(Exception ex, string message, params object[] args)
        {
            // In a real implementation, this would call NT8's logging system
            Console.WriteLine("[ERROR] " + FormatMessage(message, args) + " - Exception: " + ex.ToString());
        }

        /// <summary>
        /// Format message with arguments
        /// </summary>
        private string FormatMessage(string message, object[] args)
        {
            if (args == null || args.Length == 0)
            {
                return message;
            }

            try
            {
                return string.Format(message, args);
            }
            catch
            {
                // If formatting fails, return the original message
                return message;
            }
        }
    }
}
