public static void main(String[] args) throws Exception { DebugTools.enableLogging("INFO"); if (!new ImageInfo().testRead(args)) System.exit(1); }
/** * Attempts to enable SLF4J logging and set the root logger level. * * This method will first try to initialize the logging using * {@link #enableLogging()}. If this method returns {@code true}, the root * logger level is also set via {@link #setRootLevel(String)} using the * input level. * * @param level A string indicating the desired level * @return {@code true} if logging was successfully enabled by this method */ public static synchronized boolean enableLogging(String level) { boolean status = enableLogging(); if (status) setRootLevel(level); return status; }
/** * Attempts to enable SLF4J logging via logback or log4j. * * This will first check whether the logging has been enabled using the * return value of {@link #isEnabled()}. * * @return {@code true} if logging was successfully enabled by this method */ public static synchronized boolean enableLogging() { if (isEnabled()) return false; for (String[] toolClass : TOOL_CLASSES) { try { Class<?> k = Class.forName(toolClass[0] + toolClass[1]); Method m = k.getMethod("enableLogging"); m.invoke(null); return true; } catch (ReflectiveOperationException|LinkageError t) { // no-op. Ignore error and try the next class. } } return false; }
public boolean parseArgs(String[] args) { if (args == null || args.length == 0) { return false; } for (int i = 0; i < args.length; i++) { if (args[i].charAt(0) == '-') { if (args[i].equals("-plates")) { plates = Integer.parseInt(args[++i]); } else if (args[i].equals("-runs")) { plateAcquisitions = Integer.parseInt(args[++i]); } else if (args[i].equals("-rows")) { rows = Integer.parseInt(args[++i]); } else if (args[i].equals("-columns")) { columns = Integer.parseInt(args[++i]); } else if (args[i].equals("-fields")) { fields = Integer.parseInt(args[++i]); } else if (args[i].equals("-debug")) { DebugTools.setRootLevel("DEBUG"); } } else { if (targetDirectoryPath == null) { targetDirectoryPath = args[i]; } else { LOGGER.error("Found unknown argument: {}; exiting.", args[i]); return false; } } } return true; }
/** Reports the given exception with stack trace in an ImageJ error dialog. */ public static void reportException(Throwable t, boolean quiet, String msg) { if (quiet) return; BF.status(quiet, ""); if (t != null) { String s = DebugTools.getStackTrace(t); StringTokenizer st = new StringTokenizer(s, "\n\r"); while (st.hasMoreTokens()) IJ.log(st.nextToken()); } if (msg != null) IJ.error("Bio-Formats Importer", msg); }
/** * This method uses reflection to scan the values of this class's * static fields, returning the first matching field's name. It is * probably not very efficient, and is mainly intended for debugging. */ public static String getFieldName(int value) { return DebugTools.getFieldName(IFD.class, value); }
DebugTools.enableIJLogging(IJ.debugMode);
return true; else if (args[i].equals("-debug")) DebugTools.setRootLevel("DEBUG"); else if (args[i].equals("-stitch")) stitch = true; else if (args[i].equals("-separate")) separate = true;
/** Reports the given exception with stack trace in an ImageJ error dialog. */ public static void reportException(Throwable t, boolean quiet, String msg) { if (quiet) return; BF.status(quiet, ""); if (t != null) { String s = DebugTools.getStackTrace(t); StringTokenizer st = new StringTokenizer(s, "\n\r"); while (st.hasMoreTokens()) IJ.log(st.nextToken()); } if (msg != null) IJ.error("Bio-Formats Importer", msg); }
/** * This method uses reflection to scan the values of this class's * static fields, returning the first matching field's name. It is * probably not very efficient, and is mainly intended for debugging. */ public static String getFieldName(int value) { return DebugTools.getFieldName(IFD.class, value); }
DebugTools.enableIJLogging(IJ.debugMode);
public static void main(String[] args) throws FormatException, IOException { DebugTools.enableLogging("INFO"); ImageConverter converter = new ImageConverter(); if (!converter.testConvert(new ImageWriter(), args)) System.exit(1); System.exit(0); }
/** * Attempts to enable SLF4J logging and set the root logger level. * * This method will first try to initialize the logging using * {@link #enableLogging()}. If this method returns {@code true}, the root * logger level is also set via {@link #setRootLevel(String)} using the * input level. * * @param level A string indicating the desired level * @return {@code true} if logging was successfully enabled by this method */ public static synchronized boolean enableLogging(String level) { boolean status = enableLogging(); if (status) setRootLevel(level); return status; }
else if (args[i].equals("-noflat")) flat = false; else if (args[i].equals("-debug")) { DebugTools.setRootLevel("DEBUG"); DebugTools.setRootLevel("TRACE"); DebugTools.setRootLevel("OFF");
/** * Attempts to enable SLF4J logging via logback or log4j. * * This will first check whether the logging has been enabled using the * return value of {@link #isEnabled()}. * * @return {@code true} if logging was successfully enabled by this method */ public static synchronized boolean enableLogging() { if (isEnabled()) return false; for (String[] toolClass : TOOL_CLASSES) { try { Class<?> k = Class.forName(toolClass[0] + toolClass[1]); Method m = k.getMethod("enableLogging"); m.invoke(null); return true; } catch (ReflectiveOperationException|LinkageError t) { // no-op. Ignore error and try the next class. } } return false; }
if (exc != null) { BF.warn(quiet, "Error loading thumbnail for series #" + (series + 1)); BF.debug(DebugTools.getStackTrace(exc));
/** Executes the plugin. */ @Override public void run(ImageProcessor ip) { DebugTools.enableLogging("INFO"); if (!LibraryChecker.checkJava() || !LibraryChecker.checkImageJ()) return; HashSet<String> missing = new HashSet<String>(); LibraryChecker.checkLibrary(LibraryChecker.Library.BIO_FORMATS, missing); LibraryChecker.checkLibrary(LibraryChecker.Library.OME_JAVA_XML, missing); if (!LibraryChecker.checkMissing(missing)) return; if (exporter != null) exporter.run(); }
DebugTools.setRootLevel("INFO"); DebugTools.setRootLevel("OFF");
if (exc != null) { BF.warn(quiet, "Error loading thumbnail for series #" + (series + 1)); BF.debug(DebugTools.getStackTrace(exc));
/** Executes the plugin. */ @Override public void run(ImageProcessor ip) { DebugTools.enableLogging("INFO"); if (!LibraryChecker.checkJava() || !LibraryChecker.checkImageJ()) return; HashSet<String> missing = new HashSet<String>(); LibraryChecker.checkLibrary(LibraryChecker.Library.BIO_FORMATS, missing); LibraryChecker.checkLibrary(LibraryChecker.Library.OME_JAVA_XML, missing); if (!LibraryChecker.checkMissing(missing)) return; if (exporter != null) exporter.run(); }