Skip to content

Commit

Permalink
Huge logs are causing out of memory (heap space) exceptions in migrat…
Browse files Browse the repository at this point in the history
…ion pages #120
  • Loading branch information
raphj committed Apr 15, 2024
1 parent 1c194de commit 010578f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
Expand Up @@ -539,20 +539,27 @@ $attachment.getContentAsString()##

{{html clean=false}}
## Logs section
#set ($json = "#getJSON($obj, 'logs')")
#set ($jsonObject = $jsontool.fromString($json))
#displaySubtitle('info', 'confluencepro.migration.raport.logs.title', '', [])
<ul class="log">
#foreach ($log in $jsonObject)
#if ($objecttool.isNull($doc.getAttachment("logs.json")))
#set ($json = "#getJSON($obj, 'logs')")
#set ($jsonObject = $jsontool.fromString($json))
<ul class="log">
#foreach ($log in $jsonObject)
<li class="log-item log-item-$!{log.level.toLowerCase()}">
<div>$xwiki.formatDate($log.timeStamp) $escapetool.xml($log.message)</div>
#if ($log.throwable)
<div class="stacktrace"><pre>$escapetool.xml($stringtool.join($log.throwable, "
"))</pre></div>
#end
</li>
#end
</ul>
#else
<div id="cfmLogs">
<div class="loading-icon loading"></div>
<noscript>$services.localization.render('confluencepro.migration.raport.pleaseenablejs')</noscript>
</div>
#end
</ul>
<div class="cfmButtonGroup">
<button id="cfmResetMigration" type="button" class="btn btn-default">
$escapetool.xml($services.localization.render('confluencepro.migration.raport.reset.button'))
Expand Down Expand Up @@ -1020,13 +1027,40 @@ require(["jquery", "xwiki-l10n!confluence-job", "xwiki-job-runner"], function (
cancelButton.click();
} else {
$.ajax("?interrupt=1", {
method: 'POST',
contentType: 'text/plain',
data: '0'
method: "POST",
contentType: "text/plain",
data: "0",
});
}
}
});

const logs = document.getElementById("cfmLogs");
if (logs) {
const logsURL = XWiki.currentDocument.getURL("download") + "/logs.json";
$.get(logsURL).then(function (jsonLogs) {
const ul = document.createElement("ul");
ul.className = "log";
for (const log of jsonLogs) {
const li = document.createElement("li");
li.className = "log-item log-item-" + (log.level?.toLowerCase() || "");
const div = document.createElement("div");
const d = new Date(log.timeStamp);
const datetime = d.toLocaleDateString() + " " + d.toLocaleTimeString();
div.textContent = datetime + " " + log.message;
li.appendChild(div);
if (log.throwable) {
const divStack = document.createElement("div");
divStack.className = "stacktrace";
divStack.textContent = log.throwable.join("\n");
li.appendChild(divStack);
}
ul.appendChild(li);
}
logs.textContent = "";
logs.appendChild(ul);
});
}
});</code>
</property>
<property>
Expand Down
Expand Up @@ -102,6 +102,7 @@ confluencepro.migration.raport.problems.other.warn=Encountered {0} warnings
confluencepro.migration.raport.problems.brokenLinks.list=List of pages targeted by potentially broken links
confluencepro.migration.raport.confluencespace=Confluence space key
confluencepro.migration.raport.pageTitle=Page title
confluencepro.migration.raport.pleaseenablejs=Please enable JavaScript to see the logs
confluencepro.migration.title.label=Set the title of the migration
confluencepro.migration.source.title=Set the source package of the migration
confluencepro.migration.title.placeholder=Type the desired title...
Expand Down

0 comments on commit 010578f

Please sign in to comment.