mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Merge pull request #4288 from arduino/builder-log-levels
arduino-builder uses log levels
This commit is contained in:
commit
be2d4c6a52
@ -92,4 +92,29 @@ public class ExternalProcessOutputParserTest {
|
||||
assertEquals("", args[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser6() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("===info ||| Progress {0} ||| [79.31]");
|
||||
|
||||
assertEquals("info", output.get("level"));
|
||||
assertEquals("Progress {0}", output.get("msg"));
|
||||
Object[] args = (Object[]) output.get("args");
|
||||
assertEquals(1, args.length);
|
||||
assertEquals("79.31", args[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser7() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("===info ||| Using library {0} at version {1} in folder: {2} {3} ||| [Bridge 1.6.0 %2Fhome%2Ffederico%2Fmateriale%2Fworks_Arduino%2FArduino%2Fbuild%2Flinux%2Fwork%2Flibraries%2FBridge ]");
|
||||
|
||||
assertEquals("info", output.get("level"));
|
||||
assertEquals("Using library {0} at version {1} in folder: {2} {3}", output.get("msg"));
|
||||
Object[] args = (Object[]) output.get("args");
|
||||
assertEquals(4, args.length);
|
||||
assertEquals("Bridge", args[0]);
|
||||
assertEquals("1.6.0", args[1]);
|
||||
assertEquals("/home/federico/materiale/works_Arduino/Arduino/build/linux/work/libraries/Bridge", args[2]);
|
||||
assertEquals("", args[3]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
PreferencesMap prefs = loadPreferences(board, platform, aPackage, vidpid);
|
||||
|
||||
MessageConsumerOutputStream out = new MessageConsumerOutputStream(new ProgressAwareMessageConsumer(new I18NAwareMessageConsumer(System.out), progListener), "\n");
|
||||
MessageConsumerOutputStream out = new MessageConsumerOutputStream(new ProgressAwareMessageConsumer(new I18NAwareMessageConsumer(System.out, System.err), progListener), "\n");
|
||||
MessageConsumerOutputStream err = new MessageConsumerOutputStream(new I18NAwareMessageConsumer(System.err, Compiler.this), "\n");
|
||||
|
||||
callArduinoBuilder(board, platform, aPackage, vidpid, BuilderAction.COMPILE, new PumpStreamHandler(out, err));
|
||||
|
@ -48,7 +48,7 @@ public class ProgressAwareMessageConsumer implements MessageConsumer {
|
||||
|
||||
@Override
|
||||
public void message(String s) {
|
||||
if (s.startsWith("===Progress")) {
|
||||
if (s.startsWith("===info ||| Progress") || s.startsWith("===Progress")) {
|
||||
Map<String, Object> parsedMessage = parser.parse(s);
|
||||
Object[] args = (Object[]) parsedMessage.get("args");
|
||||
progressListener.progress(Double.valueOf(args[0].toString()).intValue());
|
||||
|
@ -50,8 +50,12 @@ public class ExternalProcessOutputParser {
|
||||
|
||||
String[] parts = SPLIT.split(s);
|
||||
|
||||
output.put("msg", parts[0]);
|
||||
output.put("args", parseArgs(parts[1]));
|
||||
int idx = 0;
|
||||
if (parts.length == 3) {
|
||||
output.put("level", parts[idx++]);
|
||||
}
|
||||
output.put("msg", parts[idx++]);
|
||||
output.put("args", parseArgs(parts[idx++]));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -39,16 +39,26 @@ import static processing.app.I18n.tr;
|
||||
|
||||
public class I18NAwareMessageConsumer implements MessageConsumer {
|
||||
|
||||
private final PrintStream ps;
|
||||
private final PrintStream out;
|
||||
private final PrintStream err;
|
||||
private final MessageConsumer parent;
|
||||
private final ExternalProcessOutputParser parser;
|
||||
|
||||
public I18NAwareMessageConsumer(PrintStream ps) {
|
||||
this(ps, null);
|
||||
public I18NAwareMessageConsumer(PrintStream out) {
|
||||
this(out, out, null);
|
||||
}
|
||||
|
||||
public I18NAwareMessageConsumer(PrintStream ps, MessageConsumer parent) {
|
||||
this.ps = ps;
|
||||
public I18NAwareMessageConsumer(PrintStream out, MessageConsumer parent) {
|
||||
this(out, out, parent);
|
||||
}
|
||||
|
||||
public I18NAwareMessageConsumer(PrintStream out, PrintStream err) {
|
||||
this(out, err, null);
|
||||
}
|
||||
|
||||
public I18NAwareMessageConsumer(PrintStream out, PrintStream err, MessageConsumer parent) {
|
||||
this.out = out;
|
||||
this.err = err;
|
||||
this.parent = parent;
|
||||
this.parser = new ExternalProcessOutputParser();
|
||||
}
|
||||
@ -57,14 +67,19 @@ public class I18NAwareMessageConsumer implements MessageConsumer {
|
||||
public void message(String s) {
|
||||
if (s.startsWith("===")) {
|
||||
Map<String, Object> parsedMessage = parser.parse(s);
|
||||
ps.println(I18n.format(tr((String) parsedMessage.get("msg")), (Object[]) parsedMessage.get("args")));
|
||||
String translatedMessage = I18n.format(tr((String) parsedMessage.get("msg")), (Object[]) parsedMessage.get("args"));
|
||||
if (!parsedMessage.containsKey("level") || "".equals(parsedMessage.get("level")) || "info".equals(parsedMessage.get("level"))) {
|
||||
out.println(translatedMessage);
|
||||
} else {
|
||||
err.println(translatedMessage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
parent.message(s);
|
||||
} else {
|
||||
ps.println(s);
|
||||
out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
3937100dc54c86cf2c29759e8ea510a05a09baf5
|
1
build/arduino-builder-linux32-1.3.7.tar.bz2.sha
Normal file
1
build/arduino-builder-linux32-1.3.7.tar.bz2.sha
Normal file
@ -0,0 +1 @@
|
||||
616acac0908c873b01b627a7902d4ffe454048bd
|
@ -1 +0,0 @@
|
||||
855b728e5515e2db1a09fe9e31b359a2f9d82689
|
1
build/arduino-builder-linux64-1.3.7.tar.bz2.sha
Normal file
1
build/arduino-builder-linux64-1.3.7.tar.bz2.sha
Normal file
@ -0,0 +1 @@
|
||||
5b427ca5f56cd38ac90b0cf2beb236dde6d7e576
|
@ -1 +0,0 @@
|
||||
635eac9c0cc8eb98973cf2fc1c851af812c99ec2
|
1
build/arduino-builder-macosx-1.3.7.tar.bz2.sha
Normal file
1
build/arduino-builder-macosx-1.3.7.tar.bz2.sha
Normal file
@ -0,0 +1 @@
|
||||
ae2c591c663ce417c03bd04cb119ae2bc721d379
|
@ -1 +0,0 @@
|
||||
1385e473a0d09a0c43fb6a7e3a934cd97f662460
|
1
build/arduino-builder-windows-1.3.7.zip.sha
Normal file
1
build/arduino-builder-windows-1.3.7.zip.sha
Normal file
@ -0,0 +1 @@
|
||||
6ec1252e3d8c5d7975b89eb221854ed3c0d7494f
|
@ -73,7 +73,7 @@
|
||||
|
||||
<property name="portable" value="false" />
|
||||
|
||||
<property name="ARDUINO-BUILDER-VERSION" value="1.3.6" />
|
||||
<property name="ARDUINO-BUILDER-VERSION" value="1.3.7" />
|
||||
|
||||
<!-- Libraries required for running arduino -->
|
||||
<fileset dir=".." id="runtime.jars">
|
||||
|
Loading…
x
Reference in New Issue
Block a user