Java Code Examples for java.util.logging.Level.CONFIG

The following are Jave code examples for showing how to use CONFIG of the java.util.logging.Level class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: SingleModuleProperties.java   View Source Code Vote up 6 votes
/** Sends info to UI handler about NetBeans APIs in use
 */
private static void logNetBeansAPIUsage(String msg, Collection<ModuleDependency> deps) {
    List<String> cnbs = new ArrayList<String>();
    for (ModuleDependency moduleDependency : deps) {
        String cnb = moduleDependency.getModuleEntry().getCodeNameBase();
        // observe just NetBeans API module usage
        if (cnb.startsWith("org.openide") || cnb.startsWith("org.netbeans")) { // NOI18N
            cnbs.add(cnb);
        }
    }

    if (cnbs.isEmpty()) {
        return;
    }

    LogRecord rec = new LogRecord(Level.CONFIG, msg);
    rec.setParameters(cnbs.toArray(new String[0]));
    rec.setResourceBundleName(SingleModuleProperties.class.getPackage().getName() + ".Bundle"); // NOI18N
    rec.setResourceBundle(NbBundle.getBundle(SingleModuleProperties.class));
    rec.setLoggerName(UI_LOG.getName());
    UI_LOG.log(rec);
}
 
Example 2
Project: incubator-netbeans   File: KeymapModel.java   View Source Code Vote up 6 votes
public void setCurrentProfile (String profileName) {
    String prev = getCurrentProfile();
    if (!prev.equals(profileName)) {
        LogRecord rec = new LogRecord(Level.CONFIG, "KEYMAP_SET_PROFILE"); // NOI18N
        rec.setParameters(new Object[]{ profileName, prev });
        rec.setResourceBundle(NbBundle.getBundle(KeymapModel.class));
        rec.setResourceBundleName(KeymapModel.class.getPackage().getName() + ".Bundle");
        rec.setLoggerName(UI_LOG.getName());
        UI_LOG.log(rec);
    }
    
    final String profile = displayNameToName(profileName);
    
    waitFinished(new Runnable() {
        public void run() {
            for (KeymapManager m : getKeymapManagerInstances()) {
                m.setCurrentProfile(profile);
            }
            profileData = null;
        }
    });
}
 
Example 3
Project: Uranium   File: ForwardLogHandler.java   View Source Code Vote up 6 votes
@Override
public void publish(LogRecord record) {
    Logger logger = getLogger(record.getLoggerName());
    Throwable exception = record.getThrown();
    Level level = record.getLevel();
    String message = getFormatter().formatMessage(record);

    if (level == Level.SEVERE) {
        logger.error(message, exception);
    } else if (level == Level.WARNING) {
        logger.warn(message, exception);
    } else if (level == Level.INFO) {
        logger.info(message, exception);
    } else if (level == Level.CONFIG) {
        logger.debug(message, exception);
    } else {
        logger.trace(message, exception);
    }
}
 
Example 4
Project: incubator-netbeans   File: LogRecordsTest.java   View Source Code Vote up 5 votes
private static Level randomLevel(Random r) {
    int lev = r.nextInt(1100);
    if (lev >= Level.SEVERE.intValue()) return Level.SEVERE;
    if (lev >= Level.WARNING.intValue()) return Level.WARNING;
    if (lev >= Level.INFO.intValue()) return Level.INFO;
    if (lev >= Level.CONFIG.intValue()) return Level.CONFIG;
    if (lev >= Level.FINE.intValue()) return Level.FINE;
    if (lev >= Level.FINER.intValue()) return Level.FINER;
    if (lev >= Level.FINEST.intValue()) return Level.FINEST;
    return Level.OFF;
}
 
Example 5
Project: incubator-netbeans   File: OpenProjectList.java   View Source Code Vote up 5 votes
private static LogRecord[] createRecord(String msg, Project[] projects) {
    if (projects.length == 0) {
        return null;
    }
    
    Map<String,int[]> counts = new HashMap<String,int[]>();
    for (Project p : projects) {
        String n = p.getClass().getName();
        int[] cnt = counts.get(n);
        if (cnt == null) {
            cnt = new int[1];
            counts.put(n, cnt);
        }
        cnt[0]++;
    }
    
    Logger logger = Logger.getLogger("org.netbeans.ui.projects"); // NOI18N
    LogRecord[] arr = new LogRecord[counts.size()];
    int i = 0;
    for (Map.Entry<String,int[]> entry : counts.entrySet()) {
        LogRecord rec = new LogRecord(Level.CONFIG, msg);
        rec.setParameters(new Object[] { entry.getKey(), afterLastDot(entry.getKey()), entry.getValue()[0] });
        rec.setLoggerName(logger.getName());
        rec.setResourceBundle(NbBundle.getBundle(OpenProjectList.class));
        rec.setResourceBundleName(OpenProjectList.class.getPackage().getName()+".Bundle");
        
        arr[i++] = rec;
    }
    
    return arr;
}
 
Example 6
Project: incubator-netbeans   File: BuildInfo.java   View Source Code Vote up 5 votes
static LogRecord logBuildInfoRec(){
    LogRecord rec = new LogRecord(Level.CONFIG, BUILD_INFO_FILE);
    List<String> buildInfo = logBuildInfo();
    if (buildInfo != null){
        rec.setParameters(buildInfo.toArray());
    }
    return rec;
}
 
Example 7
Project: incubator-netbeans   File: TimeToFailure.java   View Source Code Vote up 5 votes
static LogRecord logFailure() {
    LogRecord lr = new LogRecord(Level.CONFIG,TimeToFailure.class.getName() + ":" + totalTime);
    totalTime = 0;
    lastAction = 0;
    if(Installer.preferencesWritable) {
        prefs.putLong(MTTF,totalTime);
    }
    return lr;
}
 
Example 8
Project: Equella   File: TomcatLogRedirector.java   View Source Code Vote up 5 votes
@Override
public void publish(LogRecord record)
{
	String message = record.getMessage();
	Throwable exception = record.getThrown();
	Level level = record.getLevel();

	org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger("TomcatLog");

	// if tomcat log is not configured
	if( log4j == null )
	{
		return;
	}

	if( level == Level.SEVERE )
	{
		log4j.error(message, exception);
	}
	else if( level == Level.WARNING )
	{
		log4j.warn(message, exception);
	}
	else if( level == Level.INFO )
	{
		log4j.info(message, exception);
	}
	else if( level == Level.CONFIG )
	{
		log4j.debug(message, exception);
	}
	else
	{
		log4j.trace(message, exception);
	}
}
 
Example 9
Project: aws-codecommit-trigger-plugin   File: Log.java   View Source Code Vote up 5 votes
private void write(final Level level, final String message, final String jobName, final Object... args) {
    for (int i = 0; i < args.length; i++) {
        if (args[i] instanceof SQSTriggerQueue) {
            args[i] = ((SQSTriggerQueue) args[i]).getUrl();
        }
        else if (args[i] instanceof Throwable) {
            args[i] = ExceptionUtils.getStackTrace((Throwable)args[i]);
        }
    }

    StringBuilder source = new StringBuilder();
    if (this.autoFormat) {
        final String id = String.format("%06X", Thread.currentThread().getId());
        source
            .append("[").append(ClassUtils.getAbbreviatedName(this.clazz, 1)).append("]")
            .append("[thread-").append(id).append("]");
        if (StringUtils.isNotBlank(jobName)) {
            source.append("[job-").append(jobName).append("]");
        }
    }

    String msg = String.format(message, args);
    if (level == Level.CONFIG) {
        msg = "[DEBUG] " + msg;
    } else if (level == Level.SEVERE) {
        msg = "[ERROR] " + msg;
    }

    this.logger.logp(level, source.toString(), "", msg);
    if (this.streamHandler != null) {
        this.streamHandler.flush();
    }
}
 
Example 10
Project: incubator-netbeans   File: SlownessData.java   View Source Code Vote up 4 votes
public LogRecord getLogRec(){
    LogRecord rec = new LogRecord(Level.CONFIG, SLOWNESS_DATA);
    rec.setParameters(new Object[]{new Long(time), latestActionName, slownessType});
    return rec;
}
 
Example 11
Project: Pogamut3   File: BaseTest.java   View Source Code Vote up 4 votes
protected Level getLogLevel() {
	if (log.getLevel() == Level.ALL) return Level.FINEST;
	if (log.getLevel() == Level.OFF) return Level.WARNING;
	if (log.getLevel() == Level.CONFIG) return Level.WARNING;
	return log.getLevel();
}