Skip to content

Commit

Permalink
Don't crash if there's no logging handler installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehearn committed May 21, 2014
1 parent 467124a commit a07a810
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import java.io.Writer;
import java.text.MessageFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.*;

/**
* A Java logging formatter that writes more compact output than the default.
Expand All @@ -40,7 +37,10 @@ public class BriefLogFormatter extends Formatter {
/** Configures JDK logging to use this class for everything. */
public static void init() {
logger = Logger.getLogger("");
logger.getHandlers()[0].setFormatter(new BriefLogFormatter());
final Handler[] handlers = logger.getHandlers();
// In regular Java there is always a handler. Avian doesn't install one however.
if (handlers.length > 0)
handlers[0].setFormatter(new BriefLogFormatter());
}

public static void initVerbose() {
Expand Down

0 comments on commit a07a810

Please sign in to comment.