logError() public static method

log an error
public static logError ( string logmessage ) : void
logmessage string the error message
return void
コード例 #1
0
        /// <summary>
        /// log a message to the EA output window. If requested the message will also be logged to the logfile
        /// </summary>
        /// <param name="model">the model on which to show the output</param>
        /// <param name="outputName">the name of the output window</param>
        /// <param name="message">the message to show</param>
        /// <param name="elementID">the element ID to associate with the message. Can be used by add-ins when they implement EA_OnOutput...</param>
        /// <param name="logType">the type of logging to the logfile</param>
        public static void log(Model model, string outputName, string message, int elementID = 0, LogTypeEnum logType = LogTypeEnum.none)
        {
            var logger = getOutputLogger(model, outputName);

            //log to logfile if needed
            switch (logType)
            {
            case LogTypeEnum.none:
                //log to output
                logger.logToOutput($"{DateTime.Now.ToString("hh:mm:ss.fff")} {message}", elementID);
                break;

            case LogTypeEnum.log:
                Logger.log(message);
                //log to output
                logger.logToOutput($"{DateTime.Now.ToString("hh:mm:ss.fff")} {message}", elementID);
                break;

            case LogTypeEnum.warning:
                message = "Warning: " + message;
                Logger.logWarning(message);
                //log to output
                logger.logWarning($"{DateTime.Now.ToString("hh:mm:ss.fff")} {message}", elementID);
                break;

            case LogTypeEnum.error:
                message = "Error: " + message;
                Logger.logError(message);
                //log to output
                logger.logError($"{DateTime.Now.ToString("hh:mm:ss.fff")} {message}", elementID);
                break;
            }
        }
 /// <summary>
 /// Execute a static method on the
 /// </summary>
 /// <param name="qualifiedClassName"></param>
 /// <param name="operationName"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public object executeStaticMethod(string qualifiedClassName, string operationName, object parameters)
 {
     try
     {
         foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
         {
             foreach (var type in assembly.GetTypes())
             {
                 if (type.Namespace + "." + type.Name == qualifiedClassName &&
                     type.IsClass)
                 {
                     var methodInfo = type.GetMethod(operationName, (BindingFlags.Static | BindingFlags.Public));
                     if (methodInfo != null)
                     {
                         return(methodInfo.Invoke(null, (object[])parameters));
                     }
                 }
             }
         }
         throw new ArgumentException($"Static method {qualifiedClassName}.{operationName}() does not exist or is not loaded");
     }
     catch (Exception e)
     {
         Logger.logError(e.Message + Environment.NewLine + e.StackTrace);
         if (e.InnerException != null)
         {
             Logger.logError(e.InnerException.Message + Environment.NewLine + e.InnerException.StackTrace);
         }
         throw e;
     }
 }
        /// <summary>
        /// log a message to the EA output window. If requested the message will also be logged to the logfile
        /// </summary>
        /// <param name="model">the model on which to show the output</param>
        /// <param name="outputName">the name of the output window</param>
        /// <param name="message">the message to show</param>
        /// <param name="elementID">the element ID to associate with the message. Can be used by add-ins when they implement EA_OnOutput...</param>
        /// <param name="logType">the type of logging to the logfile</param>
        public static void log(Model model, string outputName, string message, int elementID = 0, LogTypeEnum logType = LogTypeEnum.none)
        {
            var logger = getOutputLogger(model, outputName);

            //log to logfile if needed
            switch (logType)
            {
            case LogTypeEnum.log:
                Logger.log(message);
                break;

            case LogTypeEnum.warning:
                message = "Warning: " + message;
                Logger.logWarning(message);
                break;

            case LogTypeEnum.error:
                message = "Error: " + message;
                Logger.logError(message);
                break;
            }
            //log to output
            logger.logToOutput(message, elementID);
        }