Class BugReportBundle
The file list is a deliberate manifest rather than a directory scan. MegaMek's log directory also accumulates
one gamelog*.html combat report per game and a Bot_*.mul unit list per bot per game, so a working
installation can hold hundreds of megabytes there. Sweeping the directory wholesale would produce an archive far
too large to attach, while a naive *.log filter would miss the combat report, which is usually the single
most useful artifact in a MegaMek bug report.
The text logs and the combat reports can live in different directories. Log4j always writes the text logs to
"logs" under the working directory, as set in mmconf/log4j2.xml, while the combat
reports follow the player's log directory preference. The two are the same folder unless the player has relocated
the reports.
The archive is capped at MAX_ARCHIVE_BYTES. Candidates are added in priority order and any that would
push the total past the cap are skipped and named in the returned BugReportBundle.BundleResult, so the caller can tell the
player exactly what was left out instead of silently truncating.
This class deliberately has no Swing or game-state dependencies so that it can be exercised headlessly.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe outcome of writing a bug report archive.static final recordWhere a bug report's files come from. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longGitHub refuses issue attachments larger than 25 MB, whatever the file type.static final StringThe archive entry holding the version, OS and Java details.static final StringThe directory Log4j writes the text logs to, relative to the working directory. -
Constructor Summary
ConstructorsConstructorDescriptionBugReportBundle(BugReportBundle.Sources sources) Creates a bundle description. -
Method Summary
Modifier and TypeMethodDescriptionstatic FilenewestGameSummaryDirectory(File minimapDirectory) Finds the most recently changed game summary folder, for when there is no current game to name one.Writes the archive, adding candidates in priority order until the size cap is reached.
-
Field Details
-
MAX_ARCHIVE_BYTES
public static final long MAX_ARCHIVE_BYTESGitHub refuses issue attachments larger than 25 MB, whatever the file type.- See Also:
-
SYSTEM_INFO_ENTRY_NAME
The archive entry holding the version, OS and Java details.- See Also:
-
TEXT_LOG_DIRECTORY
The directory Log4j writes the text logs to, relative to the working directory. Both MegaMek's and MekHQ'smmconf/log4j2.xmluse it, so it holds MekHQ's logs too when MegaMek runs inside MekHQ.- See Also:
-
-
Constructor Details
-
BugReportBundle
Creates a bundle description. Nothing is read from disk untilwriteTo(File)is called.- Parameters:
sources- where the report's files come from
-
-
Method Details
-
writeTo
Writes the archive, adding candidates in priority order until the size cap is reached.Reaching the cap is not an error: remaining candidates are recorded as skipped and the archive is still completed, because a partial bundle is far more useful to a maintainer than none.
- Parameters:
archiveFile- the zip file to create, overwriting any existing file at that path- Returns:
- a description of what was written
- Throws:
IOException- if the archive itself cannot be created or written
-
newestGameSummaryDirectory
Finds the most recently changed game summary folder, for when there is no current game to name one. A game that crashed or was abandoned leaves its folder behind, and that is often the game the report is about.- Parameters:
minimapDirectory- the folder holding one sub-folder per game, normallygameSummaries/minimap- Returns:
- the newest game folder, or
nullwhen there is none
-