Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #12 Allow -verbose option for "ceylon" command

  • Loading branch information...
commit 32bd6b6fb9c0ba1275327b402aab54ac3a425395 1 parent bc555e9
Tako Schotanus quintesse authored
9 spi/src/main/java/ceylon/modules/Configuration.java
View
@@ -57,6 +57,11 @@
*/
public String src;
+ /**
+ * Verbose debug output
+ */
+ public boolean verbose;
+
// Non-Ceylon
public String executable;
public boolean cacheContent;
@@ -102,6 +107,9 @@ public int setArgument(String name, ArgumentType type, String[] values, int i) {
case REPOSITORY:
repositories.add(values[arg]);
break;
+ case VERBOSE:
+ verbose = true;
+ break;
case HELP:
printUsage(0);
break;
@@ -137,6 +145,7 @@ private void printUsage(int exitCode) {
" " + homeRepo + "\n");
System.err.print(
" -src path: Source path (default: source)\n"
+ + " -verbose: Output messages about what the runtime is doing\n"
+ " -help: Prints help usage\n"
+ " -version: Prints version number\n"
+ " moduleName/version: Module name and version to run (required)\n"
32 spi/src/main/java/ceylon/modules/Main.java
View
@@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
+import java.util.logging.Level;
import java.util.logging.Logger;
import ceylon.modules.spi.ArgumentType;
@@ -42,16 +43,6 @@
*/
public static void main(String[] args) throws Throwable {
try {
- for (Handler handler : Logger.getLogger("").getHandlers()) {
- // This is a hack, but at least it works. With a property file our log
- // formatter has to be in the boot class path. This way it doesn't.
- if (handler instanceof ConsoleHandler)
- handler.setFormatter(CeylonLogFormatter.INSTANCE);
- }
- } catch (Throwable ex) {
- System.err.println("Warning: log configuration failed: " + ex.getMessage());
- }
- try {
execute(args);
} catch (CeylonRuntimeException cre) {
System.err.println("Error: " + cre.getMessage() + (cre.getCause() != null ? " [" + cre.getCause().getMessage() + "]" : ""));
@@ -74,9 +65,28 @@ public static void main(String[] args) throws Throwable {
public static void execute(String[] args) throws Exception {
Configuration conf = parseArgs(args);
String exe = conf.executable;
- if (exe == null)
+ if (exe == null) {
throw new CeylonRuntimeException("Missing -executable argument");
+ }
+ try {
+ for (Handler handler : Logger.getLogger("").getHandlers()) {
+ // This is a hack, but at least it works. With a property file our log
+ // formatter has to be in the boot class path. This way it doesn't.
+ if (handler instanceof ConsoleHandler) {
+ handler.setFormatter(CeylonLogFormatter.INSTANCE);
+ if (conf.verbose) {
+ handler.setLevel(Level.ALL);
+ }
+ }
+ }
+ if (conf.verbose) {
+ Logger.getLogger("com.redhat.ceylon.cmr").setLevel(Level.ALL);
+ }
+ } catch (Throwable ex) {
+ System.err.println("Warning: log configuration failed: " + ex.getMessage());
+ }
+
Executable executable = createInstance(Executable.class, exe);
executable.execute(conf);
}
1  spi/src/main/java/ceylon/modules/spi/Argument.java
View
@@ -27,6 +27,7 @@
RUN("run", ArgumentType.CEYLON, 1),
REPOSITORY("rep", ArgumentType.CEYLON, 1),
SOURCE("src", ArgumentType.CEYLON, 1),
+ VERBOSE("verbose", ArgumentType.CEYLON, 0),
HELP("help", ArgumentType.CEYLON, 0, "h", "-help"),
VERSION("version", ArgumentType.CEYLON, 0, "v", "-version");

2 comments on commit 32bd6b6

Stéphane Épardaud
Owner

A fucking-mazing :) Well done!

Tako Schotanus
Collaborator

Well finally with the debugger it was easy figuring out where the logger was cutting off the output. Turned out we needed to set the output level on both the handlers and the logger itself. Maybe there's another better way, but this works.

Please sign in to comment.
Something went wrong with that request. Please try again.