Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Log4J xml-spam #1460

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/common/reducers/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3265,8 +3265,30 @@ export function launchInstance(instanceName, forceQuit = false) {
);
dispatch(updateStartedInstance({ instanceName, pid: ps.pid }));

const parseLog4J = (inputStr) => {
let l4jevts = inputStr.split("<log4j:Event");
for (let evt of l4jevts) {
if (evt == " ") continue;
evt = "<log4j:Event"+evt;
let splitQuotes = evt.split('"');
let logger = splitQuotes[1];
let level = splitQuotes[5];
let thread = splitQuotes[7];
let cdatas = inputStr.split("![CDATA[");
for (let str of cdatas) {
if (str.endsWith("><")) continue;
let strOnly = str.split("]]></log4j:Message")[0];
console.log(`[${thread}] [${logger}] [${level}] ${strOnly}`);
}
}
}

ps.stdout.on('data', data => {
console.log(data.toString());
if (data.toString().includes("log4j:Event")) {
parseLog4J(data.toString());
} else {
console.log(data.toString());
}
if (
data.toString().includes('Setting user:') ||
data.toString().includes('Initializing LWJGL OpenAL')
Expand Down