protected static void setupSidlogger(Level lvl) { if (!Level.OFF.equals(lvl)) { Filter bslf = new BoshSidLoggerFilter(); Logger BoshConnectionManagerLogger = Logger.getLogger(BoshConnectionManager.class.getName()); Logger BoshSessionLogger = Logger.getLogger(BoshSession.class.getName()); if (BoshConnectionManagerLogger.getLevel() == null || BoshSessionLogger.getLevel() == null || BoshConnectionManagerLogger.getLevel().intValue() < lvl.intValue()) { BoshConnectionManagerLogger.setLevel(lvl); BoshConnectionManagerLogger.setFilter(bslf); BoshSessionLogger.setLevel(lvl); BoshSessionLogger.setFilter(bslf); BoshConnectionManagerLogger.getParent().setFilter(bslf); } try { if (null == sidFilehandler) { sidFilehandler = new FileHandler("logs/bosh_sid.log", 10000000, 5, false); sidFilehandler.setLevel(lvl); sidFilehandler.setFilter(bslf); BoshConnectionManagerLogger.getParent().addHandler(sidFilehandler); } } catch (IOException ex) { log.log(Level.CONFIG, "Error creating BOSH SID logger" + ex); } } }
/** * @param conn The {@link Connection} * @return The URL used when {@link #startTracking(Connection, String)} was called - <code>null * </code> if connection not tracked */ String stopTracking(Connection conn) { CacheKey key = new CacheKey(conn); String url = trackedMap.remove(key); if ((logLevel != null) && (!Level.OFF.equals(logLevel)) && logger.isLoggable(logLevel)) { logger.log(logLevel, "stopTracking(" + key + ") => " + url); } return url; }
/** * @param conn The created {@link Connection} * @param url The used URL to create the connection * @return The previous assigned URL to the connection - <code>null</code> if none */ String startTracking(Connection conn, String url) { CacheKey key = new CacheKey(conn); String prev = trackedMap.put(key, (url == null) ? "" : url); if ((logLevel != null) && (!Level.OFF.equals(logLevel)) && logger.isLoggable(logLevel)) { logger.log(logLevel, "startTracking(" + key + ")[" + url + "] => " + prev); } return prev; }