



using System;
using System.Diagnostics;
using System.Globalization;

namespace InteropDotNet
{
    static class LibraryLoaderTrace
    {
        const bool printToConsole = false;
		readonly static TraceSource trace = new TraceSource("Tesseract");

        private static void Print(string message)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(message);
            Console.ResetColor();
        }

        public static void TraceInformation(string format, params object[] args)
        {
            if (printToConsole)
                Print(string.Format(CultureInfo.CurrentCulture, format, args));
            trace.TraceEvent(TraceEventType.Information, 0, string.Format(CultureInfo.CurrentCulture, format, args));
        }

        public static void TraceError(string format, params object[] args)
        {
            if (printToConsole)
                Print(string.Format(CultureInfo.CurrentCulture, format, args));
            trace.TraceEvent(TraceEventType.Error, 0, string.Format(CultureInfo.CurrentCulture, format, args));
        }

        public static void TraceWarning(string format, params object[] args)
        {
            if (printToConsole)
                Print(string.Format(CultureInfo.CurrentCulture, format, args));
            trace.TraceEvent(TraceEventType.Warning, 0, string.Format(CultureInfo.CurrentCulture, format, args));
        }
    }
}
