Exemplo n.º 1
0
    public static Item?CreateItemSafe(this IRecipe recipe, LogMethod?log = null)
    {
        try {
            return(recipe.CreateItem());
        } catch (Exception ex) {
            log?.Invoke($"Unable to create item instance for recipe \"{recipe.Name}\".", LogLevel.Warn, ex);
        }

        return(null);
    }
Exemplo n.º 2
0
 public static void LogWarning(string msg)
 {
     if (internalLogWarning != null)
     {
         internalLogWarning.Invoke(msg);
     }
     else
     {
         Debug.LogWarning(msg);
     }
 }
Exemplo n.º 3
0
 public static void LogError(string msg)
 {
     if (internalLogError != null)
     {
         internalLogError.Invoke(msg);
     }
     else
     {
         Debug.LogError(msg);
     }
 }
Exemplo n.º 4
0
        private void ToClient(LogMessage logMessage, string formattedLogMessage)
        {
            //' Dont wait for it
            //' If you raise asynchronously, multiple listeners would be processing your event at the same time.
            //' At the very least, that requires a thread-safe EventArg class.
            //ThreadPool.QueueUserWorkItem(
            //    Sub()

            lock (_ThreadSafeClient)
            {
                // Thread safe property usage
                // Run client programmer's method asynchronously
                //LogMethod?.BeginInvoke(logMessage, formattedLogMessage, Nothing, Nothing)
                LogMethod?.Invoke(logMessage, formattedLogMessage);
                // Event
                OnNewLogMessage(this, new LoggerEventArgs(logMessage, formattedLogMessage));
            }

            //    End Sub)
        }