/// <summary> /// The method to call in case of logging. /// </summary> /// <param name="message">The message to log.</param> private void Log(string message) { if (SettingConfig.LogAction != null && SettingConfig.LogLevel > LogLevel.Silent) { if (SettingConfig.DebugMode == DebugMode.RealTimeAndMemory) { SettingConfig.LogAction( // Add time info (skip memory info for these log messages) LoggingGetRealTimeValue() + _loggingColumnSep + " " + // Actually add the message message); } else if (SettingConfig.DebugMode == DebugMode.RealTime) { SettingConfig.LogAction( // Add time info LoggingGetRealTimeValue() + _loggingColumnSep + " " + // Actually add the message message); } } }
/// <summary> /// Method that is called by the async logging timer. /// </summary> /// <param name="state">The state (not used).</param> private void TimedLog(object state) { if (SettingConfig.LogAction != null && SettingConfig.LogLevel > LogLevel.Silent) { // Write headline if not already done if (!_timedLogStarted) { string header = "Sim.Time".PadBoth(12) + _loggingColumnSep + "Progress".PadBoth(10) + _loggingColumnSep + "#Orders".PadBoth(9) + _loggingColumnSep + "#Bundles".PadBoth(10) + _loggingColumnSep + "Inv.".PadBoth(6) + _loggingColumnSep + "Distance".PadBoth(10) + _loggingColumnSep + "#Coll.".PadBoth(8); switch (SettingConfig.DebugMode) { case DebugMode.RealTime: header = LoggingGetRealTimeHead() + _loggingColumnSep + LoggingGetETATimeHead() + _loggingColumnSep + header; break; case DebugMode.RealTimeAndMemory: header = LoggingGetRealTimeHead() + _loggingColumnSep + LoggingGetETATimeHead() + _loggingColumnSep + header + _loggingColumnSep + LoggingGetMemoryHead(); break; default: break; } SettingConfig.LogAction(header); _timedLogStarted = true; } // Build log message string message = TimeSpan.FromSeconds(Controller.CurrentTime).ToString(IOConstants.TIMESPAN_FORMAT_HUMAN_READABLE_DAYS).PadBoth(12) + _loggingColumnSep + // The current simulation time ((Controller.Progress * 100).ToString(IOConstants.EXPORT_FORMAT_SHORT, IOConstants.FORMATTER) + "%").PadBoth(10) + _loggingColumnSep + // The progress of the simulation StatOverallOrdersHandled.ToString().PadBoth(9) + _loggingColumnSep + // The number of handled orders so far StatOverallBundlesHandled.ToString().PadBoth(10) + _loggingColumnSep + // The number of handled bundles so far ((StatStorageFillLevel * 100).ToString("F0", IOConstants.FORMATTER) + "%").PadBoth(6) + _loggingColumnSep + // The current inventory level StatOverallDistanceTraveled.ToString("F0", IOConstants.FORMATTER).PadBoth(10) + _loggingColumnSep + // The distance traveled so far StatOverallCollisions.ToString().PadBoth(8); // The number of collisions that happened so far switch (SettingConfig.DebugMode) { case DebugMode.RealTime: SettingConfig.LogAction( // Add time info LoggingGetRealTimeValue() + _loggingColumnSep + // Add ETA info LoggingGetETATimeValue() + _loggingColumnSep + // Actually add the message message); break; case DebugMode.RealTimeAndMemory: SettingConfig.LogAction( // Add time info LoggingGetRealTimeValue() + _loggingColumnSep + // Add ETA info LoggingGetETATimeValue() + _loggingColumnSep + // Actually add the message message + _loggingColumnSep + // Add memory info LoggingGetMemoryValue()); break; default: SettingConfig.LogAction(message); break; } } }