public static ExtraData createFromXml(Node wn) { try { return (ExtraData) unmarshaller.unmarshal(wn); } catch(JAXBException e) { MekHQ.getLogger().error(ExtraData.class, "createFromXml(Node)", e); return null; } }
/** * Prints the message and flushes the output stream. * * @param message */ private static void displayMessage(String message, String methodName) { logger.log(MegaMek.class, methodName, LogLevel.INFO, message); }
@Override public void endOfTurnProcessing() { getLogger().methodBegin(getClass(), "endOfTurnProcessing()"); checkForDishonoredEnemies(); checkForBrokenEnemies(); // refreshCrippledUnits should happen after checkForDishonoredEnemies, since checkForDishoneredEnemies // wants to examine the units that were considered crippled at the *beginning* of the turn and were attacked. refreshCrippledUnits(); getLogger().methodEnd(getClass(), "endOfTurnProcessing()"); }
private void loadServices() { try { for (Iterator<T> iter = loader.iterator(); iter.hasNext(); ) { final T service = iter.next(); MekHQ.getLogger().log(getClass(), "loadServices()", LogLevel.DEBUG, "Found service " + service.getModuleName()); services.put(service.getModuleName(), service); } } catch (ServiceConfigurationError err) { MekHQ.getLogger().error(getClass(), "loadServices()", err); //$NON-NLS-1$ } }
/** * Attempt to deserialize an instance of a scenario modifier from the passed-in file * @param xmlNode the node to deserialize * @return Possibly an instance of a scenario modifier list */ public static AtBScenarioModifier Deserialize(String fileName) { AtBScenarioModifier resultingList = null; try { JAXBContext context = JAXBContext.newInstance(AtBScenarioModifier.class); Unmarshaller um = context.createUnmarshaller(); File xmlFile = new File(fileName); if(!xmlFile.exists()) { MekHQ.getLogger().warning(AtBScenarioModifier.class, "Deserialize", String.format("Specified file %d does not exist", fileName)); return null; } Source inputSource = MekHqXmlUtil.createSafeXmlSource(new FileInputStream(xmlFile)); JAXBElement<AtBScenarioModifier> templateElement = um.unmarshal(inputSource, AtBScenarioModifier.class); resultingList = templateElement.getValue(); } catch(Exception e) { MekHQ.getLogger().error(ScenarioModifierManifest.class, "Deserialize", "Error Deserializing Scenario Modifier", e); } return resultingList; }
getLogger().methodBegin(getClass(), METHOD_NAME); continue; getLogger().log(getClass(), METHOD_NAME, LogLevel.DEBUG, "Processing unit " + u.getName()); if (u.isMothballed()) { getLogger().log(getClass(), METHOD_NAME, LogLevel.DEBUG, "Unit " + u.getName() + " is mothballed. Skipping."); getLogger().log(getClass(), METHOD_NAME, LogLevel.DEBUG, "Unit " + u.getName() + " -- Value = " + value.toPlainString()); getLogger().log(getClass(), METHOD_NAME, LogLevel.DEBUG, "Unit " + u.getName() + " -- Adding commander (" + p.getName() + "" + calcAdminSupportHoursNeeded(); getLogger().methodEnd(getClass(), METHOD_NAME);
private void loadFactionHints() throws DOMException, ParseException { final String METHOD_NAME = "loadFactionHints()"; //$NON-NLS-1$ MekHQ.getLogger().info(getClass(), METHOD_NAME, "Starting load of faction hint data from XML..."); //$NON-NLS-1$ Document xmlDoc = null; MekHQ.getLogger().error(getClass(), METHOD_NAME, ex); addNeutralExceptions(f, wn); } else { MekHQ.getLogger().error(getClass(), METHOD_NAME, "Invalid faction code in factionhints.xml: " + f); //$NON-NLS-1$ deepPeriphery.add(f); } else { MekHQ.getLogger().error(getClass(), METHOD_NAME, "Invalid faction code in factionhints.xml: " + f); //$NON-NLS-1$ majorPowers.add(f); } else { MekHQ.getLogger().error(getClass(), METHOD_NAME, "Invalid faction code in factionhints.xml: " + f); //$NON-NLS-1$ addContainedFaction(outer, inner, start, end, fraction, opponents); } else { MekHQ.getLogger().error(getClass(), METHOD_NAME, "Invalid faction code in factionhints.xml: " + outer + "/" + inner); //$NON-NLS-1$
/** * Uses the "lance staggered deployment" algorithm to determine individual deployment turns * Not actually implemented currently. * @param botForce The list of entities to process. */ private static void setDeploymentTurnsStaggeredByLance(List<Entity> entityList) { MekHQ.getLogger().warning(AtBDynamicScenarioFactory.class, "setDeploymentTurnsStaggeredByLance", "Deployment Turn - Staggered by Lance not implemented"); }
ChassisRecord cRec = chassis.get(chassisKey); if (cRec == null) { DefaultMmLogger.getInstance().error(getClass(), METHOD_NAME, "Could not locate chassis " + chassisKey); continue; FactionRecord salvageFaction = factions.get(fKey); if (salvageFaction == null) { DefaultMmLogger.getInstance().debug(getClass(), METHOD_NAME, "Could not locate faction " + fKey + " for " + fRec.getKey() + " salvage"); } else {
protected AeroGroundPathFinder(IGame game) { this.game = game; getLogger().setLogLevel(LOGGER_CATEGORY, LogLevel.DEBUG); }
/** * Write debug information to the logs. * * @param methodName Name of the method logging is coming from * @param message Message to log */ protected void logDebug(String methodName, String message) { DefaultMmLogger.getInstance().debug(getClass(), methodName, message); }
void updateAvailableSupport() { final String METHOD_NAME = "updateAvailableSupport()"; getLogger().methodCalled(getClass(), METHOD_NAME); for (Person p : getCampaign().getActivePersonnel()) { if (p.isTech()) { updateTechSupportHours(p); } else if (p.isDoctor()) { updateMedicalSupportHours(p); } else if (p.isAdmin()) { updateAdministrativeSupportHours(p); } } }
if (getLogger().getLogLevel(LOGGING_CATEGORY).toInt() > LogLevel.WARNING.toInt()) { sendChat("deploying unit " + getEntity(entityNum).getChassis(), LogLevel.INFO);
public BotForce() { this.entityList = new ArrayList<Entity>(); try { behaviorSettings = BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR.getCopy(); } catch (PrincessException ex) { MekHQ.getLogger().log(getClass(), "BotForce()", LogLevel.ERROR, //$NON-NLS-1$ "Error getting Princess default behaviors"); //$NON-NLS-1$ MekHQ.getLogger().error(getClass(), "BotForce()", ex); //$NON-NLS-1$ } };
/** * Attempt to deserialize an instance of a scenario modifier list from the passed-in file * @param xmlNode the node to deserialize * @return Possibly an instance of a scenario modifier list */ public static ScenarioModifierManifest Deserialize(String fileName) { ScenarioModifierManifest resultingList = null; try { JAXBContext context = JAXBContext.newInstance(ScenarioModifierManifest.class); Unmarshaller um = context.createUnmarshaller(); File xmlFile = new File(fileName); if(!xmlFile.exists()) { MekHQ.getLogger().warning(ScenarioModifierManifest.class, "Deserialize", String.format("Specified file %s does not exist", fileName)); return null; } Source inputSource = MekHqXmlUtil.createSafeXmlSource(new FileInputStream(xmlFile)); JAXBElement<ScenarioModifierManifest> templateElement = um.unmarshal(inputSource, ScenarioModifierManifest.class); resultingList = templateElement.getValue(); } catch(Exception e) { MekHQ.getLogger().error(ScenarioModifierManifest.class, "Deserialize", "Error Deserializing Scenario Modifier List", e); } return resultingList; } }
/** * Constructs a list of a faction's potential enemies based on common borders. * @param employerName The shortName of the employer faction * @return A list of faction that share a border */ public List<String> getEnemyList(String employerName) { Faction employer = Faction.getFaction(employerName); if (null == employer) { MekHQ.getLogger().warning(getClass(), "getEnemyList(String)", //$NON-NLS-1$ "Unknown faction key: " + employerName); //$NON-NLS-1$ return Collections.emptyList(); } return getEnemyList(Faction.getFaction(employerName)); }
public void enableSimplifiedLogging() { if (simpleLoggingConfigured.get()) { return; } simpleLoggingConfigured.set(true); DefaultMmLogger.getInstance().setLogLevel(CAT_MEGAMEK, LogLevel.INFO); // Check for updated logging properties every 30 seconds. DOMConfigurator.configureAndWatch(LOG_CONFIG_FILE_PATH, 30000); } }
public HashMap<String, Integer> getSalvage(int era) { if (salvage.containsKey(era) && salvage.get(era).size() > 0) { return salvage.get(era); } HashMap<String,Integer> retVal = new HashMap<String, Integer>(); if (retVal.size() == 0 && parentFactions.size() > 0) { for (String pKey : parentFactions) { FactionRecord fRec = RATGenerator.getInstance().getFaction(pKey); if (fRec != null) { for (String fKey : fRec.getSalvage(era).keySet()) { retVal.merge(fKey, fRec.getSalvage(era).get(fKey), Integer::sum); } } else { DefaultMmLogger.getInstance().debug(getClass(), "getSalvage(int)", "RATGenerator: could not locate salvage faction " + pKey + " for " + key); } } } salvage.put(era, retVal); return retVal; }
public void writePlanet(OutputStream out, Planet planet) { try { marshaller.marshal(planet, out); } catch (Exception e) { MekHQ.getLogger().error(getClass(), "writePlanet(OutputStream,Planet)", e); //$NON-NLS-1$ } }
private void handleError(String methName, Throwable t, boolean quiet) { DefaultMmLogger.getInstance().log(getClass(), methName, LogLevel.ERROR, t); if (quiet) return; JOptionPane.showMessageDialog(this, t.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE); } }