示例#1
0
  public static synchronized void createLoggers(boolean reinit) {

    if (m_initialized == true && reinit == false) {
      return;
    }

    if (!m_initialized) {
      Logger.getLogger("").removeHandler(Logger.getLogger("").getHandlers()[0]);
    }

    if (m_initialized) {
      m_severeLogger.removeHandler(m_severeLogger.getHandlers()[0]);
      m_nonSevereLogger.removeHandler(m_nonSevereLogger.getHandlers()[0]);
    }

    Handler severeHandler = new AMyConsoleHandler(System.err);
    severeHandler.setFormatter(new SingleLineFormatter());
    m_severeLogger.addHandler(severeHandler);
    m_severeLogger.setLevel(getLoggingLevel());

    Handler nonSevereHandler = new AMyConsoleHandler(System.out);
    nonSevereHandler.setFormatter(new SingleLineFormatter());
    m_nonSevereLogger.addHandler(nonSevereHandler);
    m_nonSevereLogger.setLevel(getLoggingLevel());

    m_initialized = true;
  }
示例#2
0
  public static synchronized void setLoggingLevel(String loggingLevel) {

    if (loggingLevel.toLowerCase().equals("severe")) {
      m_loggingLevel = Level.SEVERE;
    } else if (loggingLevel.toLowerCase().equals("warning")) {
      m_loggingLevel = Level.WARNING;
    } else if (loggingLevel.toLowerCase().equals("info")) {
      m_loggingLevel = Level.INFO;
    } else if (loggingLevel.toLowerCase().equals("config")) {
      m_loggingLevel = Level.CONFIG;
    } else if (loggingLevel.toLowerCase().equals("fine")) {
      m_loggingLevel = Level.FINE;
    } else if (loggingLevel.toLowerCase().equals("finer")) {
      m_loggingLevel = Level.FINER;
    } else if (loggingLevel.toLowerCase().equals("finest")) {
      m_loggingLevel = Level.FINEST;
    } else {
      m_loggingLevel = Level.WARNING;
    }

    if (m_initialized) {
      m_severeLogger.setLevel(m_loggingLevel);
      m_nonSevereLogger.setLevel(m_loggingLevel);
    }
  }
  public void preprocess(Run run) {
    File logFile = new File(getRunDir(run), "genetik.log");

    try {
      SimpleFileHandler fh = new SimpleFileHandler(logFile);
      fh.setFormatter(new CompactFormatter());

      Logger logger = Logger.getLogger(GenetikConstants.LOGGER);
      logger.setLevel(Level.INFO);
      logger.setUseParentHandlers(false);
      Handler handlers[] = logger.getHandlers();

      logger.addHandler(fh);

      for (Handler h : handlers) {
        logger.removeHandler(h);

        if (h instanceof SimpleFileHandler) h.close(); // close our old one
      }
    } catch (Exception exp) {
      throw new IllegalArgumentException(
          "Unable to create log file at " + logFile.getAbsolutePath());
    }

    super.preprocess(run);
  }
示例#4
0
 public void setUp() throws Exception {
   super.setUp();
   log.setLevel(Logger.LEVEL_DEBUG);
   if (dig == null) {
     dig = MessageDigest.getInstance(hashAlgorithm);
   }
   mau = new MockArchivalUnit(new MockPlugin());
   cus = new MockCachedUrlSet(mau, null);
   cus.setHashItSource(Collections.EMPTY_LIST);
   TimeBase.setSimulated();
 }
示例#5
0
    // Private method to reset an invidual target logger.
    private void resetLogger(String name) {
	Logger logger = getLogger(name);
	if (logger == null) {
	    return;
	}
	// Close all the Logger's handlers.
	Handler[] targets = logger.getHandlers();
	for (int i = 0; i < targets.length; i++) {
	    Handler h = targets[i];
	    logger.removeHandler(h);
	    try {
	        h.close();
	    } catch (Exception ex) {
		// Problems closing a handler?  Keep going...
	    }
	}
	if (name != null && name.equals("")) {
	    // This is the root logger.
	    logger.setLevel(defaultLevel);
	} else {
	    logger.setLevel(null);
	}
    }
示例#6
0
  public static Logger initLogger() {
    Logger initlogger = Logger.getLogger(settings.getMainClass());
    initlogger.setLevel(settings.getLogLevel());
    boolean addconsole = false;
    if (settings.getLogToFile()) {
      try {
        Handler handler = new FileHandler(settings.getLogFile(), true);
        handler.setFormatter(new SimpleFormatter());
        initlogger.addHandler(handler);
      } catch (Exception e) {
        Logger().warning("Could not set logfile " + settings.getLogFile() + ": " + e.getMessage());
        addconsole = true;
      }
    }
    addconsole = settings.getLogToConsole() || addconsole;
    if (addconsole) {
      initlogger.addHandler(new ConsoleHandler());
    }
    // restore original log state
    logger.setLevel(templevel);
    templevel = null;

    return initlogger;
  }
示例#7
0
    // Private method to set a level on a logger.
    // If necessary, we raise privilege before doing the call.
    private static void doSetLevel(final Logger logger, final Level level) {
	SecurityManager sm = System.getSecurityManager();
	if (sm == null) {
	    // There is no security manager, so things are easy.
	    logger.setLevel(level);
	    return;
	} 
	// There is a security manager.  Raise privilege before
	// calling setLevel.
	AccessController.doPrivileged(new PrivilegedAction() {
	    public Object run() {
	        logger.setLevel(level);
		return null;
	    }});
    }
  public UkkonenSuffixTree() {
    logger =
        Logger.getLogger(
            "edu.psu.compbio.seqcode.gse.projects.chipseq.assembler.UkkonenSuffixTree");
    isLogging = true;
    minLogLevel = Level.SEVERE;
    logger.setFilter(new LoggingFilter());
    logger.addHandler(new LoggingHandler(System.err, false));
    logger.setUseParentHandlers(false);
    logger.setLevel(Level.SEVERE);

    logger.log(Level.FINE, "Logger setup complete.");

    strings = new Vector<TreeString>();
    terminal = '$';
    root = new TreeNode(null);
    totalStringEdges = new Vector<TreeEdge>();
    extState = null;
  }
示例#9
0
    // Private method to be called when the configuration has
    // changed to apply any level settings to any pre-existing loggers.
    synchronized private void setLevelsOnExistingLoggers() {
	Enumeration enum = props.propertyNames();
	while (enum.hasMoreElements()) {
	    String key = (String)enum.nextElement();
	    if (!key.endsWith(".level")) {
		// Not a level definition.
		continue;
	    }
	    int ix = key.length() - 6;
	    String name = key.substring(0, ix);
	    Level level = getLevelProperty(key, null);
	    if (level == null) {
		System.err.println("Bad level value for property: " + key);
		continue;
	    }
	    Logger l = getLogger(name);
	    if (l == null) {
		continue;
	    }
	    l.setLevel(level);
	}
    }
示例#10
0
  private void initLogger() {
    ConsoleHandler consoleHandler = null;

    Logger rootLogger = LogManager.getLogManager().getLogger("");
    Handler[] handlers = rootLogger.getHandlers();
    for (Handler handler : handlers) {
      if (handler instanceof ConsoleHandler) {
        consoleHandler = (ConsoleHandler) handler;
        rootLogger.removeHandler(handler);
      }
    }

    logger = Logger.getLogger(contextId);
    logger.setLevel(logLevel);
    if (!logLevel.equals(Level.OFF)) {
      LogFormatter formatter = new LogFormatter();
      if (consoleLog) {
        if (consoleHandler == null) {
          consoleHandler = new ConsoleHandler();
        }
        consoleHandler.setFormatter(formatter);
        consoleHandler.setLevel(logLevel);
        logger.addHandler(consoleHandler);
      }
      String userHomePath = getProperty("user.home", ".");
      File logDir = new File(userHomePath, '.' + contextId + "/log");
      logDir.mkdirs();
      String logFilePattern = new File(logDir, contextId + "-%g.log").getPath();
      try {
        FileHandler fileHandler = new FileHandler(logFilePattern);
        fileHandler.setFormatter(formatter);
        fileHandler.setLevel(logLevel);
        logger.addHandler(fileHandler);
      } catch (IOException e) {
        System.err.println("Error: Failed to create log file: " + logFilePattern);
      }
    }
  }
示例#11
0
 static {
   // Use anonymous logger (System.err), until settings read, set initial level to WARNING
   logger = Logger.getAnonymousLogger();
   templevel = logger.getLevel();
   logger.setLevel(Level.WARNING);
 }
示例#12
0
 static {
   _libraryLogger.setLevel(Level.INFO);
 }