Exemplo n.º 1
0
 public static bool CreateAndReturnEngine_Test(string text, out LogEngine engine)
 {
     return CreateAndReturnEngine(text, out engine);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new wurm-log reading worker for specified wurm character. 
 /// Returns true if succeeded, will fail if worker already running for this wurm character,
 /// or there is no path/config data available to initialize it.
 /// Note: subscribing and unsubscribing to this API automatically handles this process!
 /// </summary>
 /// <param name="playerName">full wurm character name, case-sensitive</param>
 /// <param name="dailyLoggingMode">optional, recommended null, allows overriding autodetected logging mode;
 /// true = daily logging mode; false = monthly logging mode</param>
 /// <returns></returns>
 public static bool CreateEngine(string playerName, bool? dailyLoggingMode = null)
 {
     try
     {
         if (dailyLoggingMode == null)
         {
             WurmClient.Configs.ConfigData config = WurmClient.PlayerConfigurations.GetThisPlayerConfig(playerName);
             WurmClient.Configs.EnumLoggingType[] allowedTypes = 
             { 
                 WurmClient.Configs.EnumLoggingType.Daily,
                 WurmClient.Configs.EnumLoggingType.Monthly 
             };
             if (config.EventAndOtherLoggingModesAreEqual(allowedTypes))
             {
                 if (config.EventLoggingType == WurmClient.Configs.EnumLoggingType.Daily) dailyLoggingMode = true;
                 else if (config.EventLoggingType == WurmClient.Configs.EnumLoggingType.Monthly) dailyLoggingMode = false;
                 else
                 {
                     Logger.LogError("Unknown logging mode for this character: " + (playerName ?? "NULL"), THIS);
                     return false;
                 }
             }
             else
             {
                 throw new Exception(string.Format("Wurm client logging modes are set incorrectly: Event: {0}, Other: {1}",
                     config.EventLoggingType, config.OtherLoggingType));
             }
         }
         LogEngine newEngine = new LogEngine(playerName, dailyLoggingMode.Value);
         LogEngines.Add(playerName, newEngine);
         return true;
     }
     catch (Exception _e)
     {
         Logger.LogError("Could not create log engine for " + (playerName ?? "NULL") + " ; daily logging: " + dailyLoggingMode.ToString(), THIS, _e);
         return false;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Method intended for garbage collection tests
 /// </summary>
 /// <param name="playerName"></param>
 /// <param name="engine"></param>
 /// <param name="dailyLoggingMode"></param>
 /// <returns></returns>
 internal static bool CreateAndReturnEngine(string playerName, out LogEngine engine, bool? dailyLoggingMode = null)
 {
     try
     {
         if (dailyLoggingMode == null)
         {
             WurmClient.Configs.ConfigData config = WurmClient.PlayerConfigurations.GetThisPlayerConfig(playerName);
             if (config.EventLoggingType == config.OtherLoggingType)
             {
                 if (config.EventLoggingType == WurmClient.Configs.EnumLoggingType.Daily) dailyLoggingMode = true;
                 else if (config.EventLoggingType == WurmClient.Configs.EnumLoggingType.Monthly) dailyLoggingMode = false;
                 else
                 {
                     engine = null;
                     Logger.LogError("Could not create engine because of unsupported logging mode: " + config.EventLoggingType.ToString(), THIS);
                     return false;
                 }
             }
         }
         engine = new LogEngine(playerName, dailyLoggingMode.Value);
         LogEngines.Add(playerName, engine);
         Logger.LogInfo("Created engine for player " + playerName);
         return true;
     }
     catch (Exception _e)
     {
         Logger.LogError("Could not create log engine for " + playerName + " ; daily logging: " + dailyLoggingMode.ToString(), THIS, _e);
         engine = null;
         return false;
     }
 }