org.apache.log4j.Logger#isDebugEnabled ( )源码实例Demo

下面列出了org.apache.log4j.Logger#isDebugEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: serianalyzer   文件: SerianalyzerState.java
/**
 * @param typeName
 * @param methodReference
 * @param force
 */
void trackInstantiable ( String tn, MethodReference methodReference, SerianalyzerConfig cfg, boolean force ) {
    if ( force ) {
        this.forcedInstantiable.add(tn);
    }
    this.instantiableTypes.add(tn);
    Set<MethodReference> set = this.instantiatedThrough.get(tn);
    Logger cl = Verbose.getPerClassLogger(tn);
    if ( set == null ) {
        set = new HashSet<>();
        if ( this.instantiatedThrough.put(tn, set) == null ) {
            if ( cl.isDebugEnabled() ) {
                cl.debug(String.format("Adding instantiable type %s for %s", tn, methodReference)); //$NON-NLS-1$
            }
        }
    }
    set.add(methodReference.comparable());
}
 
源代码2 项目: swift-t   文件: ConstantFolder.java
private static ArgOrCV foldBuiltinOp(Logger logger, CongruentSets sets,
                                   ComputedValue<Arg> val) {
  List<Arg> inputs;
  if (val.op == Opcode.LOCAL_OP) {
    inputs = val.inputs;
  } else {
    assert(val.op == Opcode.ASYNC_OP);
    inputs = findFutureValues(sets, val);
  }

  if (logger.isTraceEnabled()) {
    logger.trace("Try constant fold: " + val + " " + inputs);
  }
  if (inputs != null) {
    // constant fold
    Arg res = OpEvaluator.eval((BuiltinOpcode)val.subop, inputs);
    if (res != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Constant fold: " + val + " => " + res);
      }
      boolean futureResult = val.op != Opcode.LOCAL_OP;
      return valFromArg(futureResult, res);
    }
  }
  return null;
}
 
源代码3 项目: openemm   文件: BaseDaoImpl.java
/**
 * Logs the sql statement. This is typically used before db executions.
 * This method is also included in select and update methods of this class, so they don't have to be called explicitly
 * @param logger
 * @param statement
 * @param parameter
 */
protected void logSqlStatement(Logger logger, String statement, Object... parameter) {
	if (logger.isDebugEnabled()) {
		if (parameter != null && parameter.length > 0) {
			logger.debug("SQL: " + statement + "\nParameter: " + getParameterStringList(parameter));
		} else {
			logger.debug("SQL: " + statement);
		}
	}
}
 
源代码4 项目: openemm   文件: BaseDaoImpl.java
/**
 * Method to update multiple data entries at once.<br />
 * Logs the statement and parameter in debug-level, executes update and logs error.<br />
 * Watch out: Oracle returns value -2 (= Statement.SUCCESS_NO_INFO) per line for success with no "lines touched" info<br />
 * 
 * @param logger
 * @param statement
 * @param values
 * @return
 */
public int[] batchupdate(Logger logger, String statement, List<Object[]> values) {
	try {
		validateStatement(statement);
		logSqlStatement(logger, statement, "BatchUpdateParameterList(Size: " + values.size() + ")");
		int[] touchedLines = getJdbcTemplate().batchUpdate(statement, values);
		if (logger.isDebugEnabled()) {
			logger.debug("lines changed by update: " + Arrays.toString(touchedLines));
		}
		return touchedLines;
	} catch (RuntimeException e) {
		logSqlError(e, logger, statement, "BatchUpdateParameterList(Size: " + values.size() + ")");
		throw e;
	}
}
 
源代码5 项目: openemm   文件: BaseDaoImpl.java
public int[] batchInsertIntoAutoincrementMysqlTable(Logger logger, String insertStatement, List<Object[]> listOfValueArrays) throws Exception {
	try {
		validateStatement(insertStatement);
		logSqlStatement(logger, insertStatement, "BatchInsertParameterList(Size: " + listOfValueArrays.size() + ")");
		
		List<Integer> generatedKeys = new ArrayList<>();

		try (final Connection connection = getDataSource().getConnection()) {
			try (final PreparedStatement preparedStatement = connection.prepareStatement(insertStatement, Statement.RETURN_GENERATED_KEYS)) {
				for (Object[] valueArray : listOfValueArrays) {
					int parameterIndex = 1;
					for (Object value : valueArray) {
						preparedStatement.setObject(parameterIndex++, value);
					}
					preparedStatement.addBatch();
				}
				preparedStatement.executeBatch();
				
				try (ResultSet resultSet = preparedStatement.getGeneratedKeys()) {
					while (resultSet.next()) {
						generatedKeys.add(resultSet.getInt(1));
					}
				}
			}
		}
		if (logger.isDebugEnabled()) {
			logger.debug("keys inserted by batch insert: " + StringUtils.join(generatedKeys, ", "));
		}
		return generatedKeys.stream().mapToInt(i->i).toArray();
	} catch (RuntimeException e) {
		logSqlError(e, logger, insertStatement, "BatchInsertParameterList(Size: " + listOfValueArrays.size() + ")");
		throw e;
	}
}
 
源代码6 项目: openemm   文件: BIRTDataSet.java
/**
 * Method to update multiple data entries at once.<br />
 * Logs the statement and parameter in debug-level, executes update and logs error.<br />
 * Watch out: Oracle returns value -2 (= Statement.SUCCESS_NO_INFO) per line for success with no "lines touched" info<br />
 * 
 * @param childClassLogger
 * @param statement
 * @param values
 * @return
 * @throws Exception
 */
public int[] batchupdateEmbedded(Logger childClassLogger, String statement, List<Object[]> values) throws Exception {
	try {
		logSqlStatement(childClassLogger, "EMBEDDED: " + statement, "BatchUpdateParameterList(Size: " + values.size() + ")");
		int[] touchedLines = getEmbeddedJdbcTemplate().batchUpdate(statement, values);
		if (childClassLogger.isDebugEnabled()) {
			childClassLogger.debug("lines changed by update: " + Arrays.toString(touchedLines));
		}
		return touchedLines;
	} catch (RuntimeException e) {
		logSqlError(e, childClassLogger, "EMBEDDED: " + statement, "BatchUpdateParameterList(Size: " + values.size() + ")");
		throw e;
	}
}
 
源代码7 项目: lutece-core   文件: AppLogService.java
/**
 * Log a message object with the DEBUG level. It is logged in application.log
 *
 * @param strLogger
 *            The Logger name
 * @param objToLog
 *            the message object to log
 */
public static void debug( String strLogger, Object objToLog )
{
    Logger logger = Logger.getLogger( strLogger );

    if ( logger.isDebugEnabled( ) )
    {
        logger.debug( objToLog );
    }
}
 
源代码8 项目: niubi-job   文件: LoggerHelper.java
public static void debug(Class<?> clazz, String message, Throwable throwable) {
    AssertHelper.notNull(message, "message can't be null!");
    if (clazz == null) {
        clazz = LoggerHelper.class;
    }
    Logger logger = Logger.getLogger(clazz);
    if (logger.isDebugEnabled() && throwable == null) {
        logger.debug(message);
    }
    if (logger.isDebugEnabled() && throwable != null) {
        logger.debug(message, throwable);
    }
}
 
源代码9 项目: reladomo   文件: MithraCacheRemoteServiceImpl.java
private CachedClassData createCachedClassData(MithraRuntimeCacheController cacheController)
{
    String name = cacheController.getClassName();
    Logger logger = getLogger(name);
    Logger batchLogger = getBatchLogger(name);
    byte sqlLevel = CachedClassData.SQL_IS_OFF;
    if (batchLogger.isDebugEnabled()) sqlLevel = CachedClassData.SQL_IS_MAX_ON;
    else if (logger.isDebugEnabled()) sqlLevel = CachedClassData.SQL_IS_ON;
    return new CachedClassData(cacheController.getCacheSize(), name,
            cacheController.isPartialCache(), sqlLevel);
}
 
源代码10 项目: serianalyzer   文件: Serianalyzer.java
/**
 * @param s
 */
private void removeSafeCalls ( MethodReference ref ) {
    MethodReference s = ref.comparable();
    if ( !this.state.removeAllKnown(Collections.singleton(s)) ) {
        return;
    }

    Set<MethodReference> calls = this.state.getMethodCallers().get(s);
    if ( calls == null ) {
        return;
    }

    for ( MethodReference caller : calls ) {
        Set<MethodReference> callerCalls = this.state.getMethodCallees().get(caller);
        if ( callerCalls != null ) {
            Logger cl = Verbose.getPerMethodLogger(s);
            if ( "<init>".equals(s.getMethod()) ) { //$NON-NLS-1$
                continue;
            }
            callerCalls.remove(s);
            if ( cl.isDebugEnabled() ) {
                cl.debug(String.format("SAFE, removing call %s from %s, remaining calls %s", s, caller, callerCalls)); //$NON-NLS-1$
            }
            if ( callerCalls.isEmpty() ) {
                cl.debug("Caller not longer has any calls"); //$NON-NLS-1$
                removeSafeCalls(caller);
            }
        }
    }
}
 
源代码11 项目: rice   文件: BufferedLogger.java
/**
 * Wraps {@link Logger#debug(String)}
 * 
 * @param pattern to format against
 * @param objs an array of objects used as parameters to the <code>pattern</code>
 */
public static final void debug(Object ... objs) {
    Logger log = getLogger();
    if (log.isDebugEnabled()) {
        log.debug(getMessage(objs));
    }
}
 
源代码12 项目: swift-k   文件: Loader.java
public static void debugText(String name, String source) {
    Logger textLogger = Logger.getLogger("swift.textfiles");
    if (textLogger.isDebugEnabled()) {
        textLogger.debug("BEGIN " + name + ":\n" + source + "\n");
        textLogger.debug("END " + name + ":");
    }
}
 
源代码13 项目: spacewalk   文件: TaskHelper.java
/**
 * Sends mail and logs the mail message if debug logging is enabled
 * @param mail - message to be sent
 * @param logger - logger assigned to the caller
 */
public static void sendMail(Mail mail, Logger logger) {
    if (logger != null && logger.isDebugEnabled()) {
        logger.debug("Sending mail message:\n" + mail.toString());
    }
    mail.send();
}
 
源代码14 项目: datawave   文件: JobSetupUtil.java
/**
 * Computes a set of ranges to scan over entries whose row is a shaded day (yyyyMMdd_shardNum), one range per day. We calculate a range per day so that we
 * can assume that all entries for a particular day go to the same mapper in a MapReduce job.
 *
 * This uses the supplied start and end date parameters that can be supplied at job start time, and if none are supplied, it uses the current day. The end
 * of the range is always set exclusively to the start of the day following the end of the supplied day (or the beginning of tomorrow if no end was
 * supplied).
 */
public static Collection<Range> computeShardedDayRange(Configuration conf, Logger log) {
    String start = conf.get(MetricsConfig.START);
    String end = conf.get(MetricsConfig.END);
    
    GregorianCalendar from = new GregorianCalendar();
    if (start != null)
        from.setTime(DateConverter.convert(start));
    from.set(Calendar.HOUR_OF_DAY, 0);
    from.set(Calendar.MINUTE, 0);
    from.set(Calendar.SECOND, 0);
    from.set(Calendar.MILLISECOND, 0);
    if (log.isDebugEnabled() && start == null)
        log.debug("Defaulting start to the beginning of today: " + from);
    
    GregorianCalendar until = new GregorianCalendar();
    if (end != null)
        until.setTimeInMillis(DateConverter.convert(end).getTime() + TimeUnit.DAYS.toMillis(1));
    until.set(Calendar.HOUR_OF_DAY, 0);
    until.set(Calendar.MINUTE, 0);
    until.set(Calendar.SECOND, 0);
    until.set(Calendar.MILLISECOND, 0);
    until.add(Calendar.DAY_OF_YEAR, 1);
    if (log.isDebugEnabled() && end == null)
        log.debug("Defaulting end to the beginning of tomorrow: " + until);
    
    if (until.compareTo(from) <= 0) {
        log.error("Warning: end date (" + until + ") is after begin date (" + from + "), swapping!");
        GregorianCalendar tmp = until;
        until = from;
        from = tmp;
    }
    
    ArrayList<Range> ranges = new ArrayList<>();
    while (from.compareTo(until) < 0) {
        String rangeStart = DateHelper.format(from.getTime());
        from.add(GregorianCalendar.DAY_OF_YEAR, 1);
        String rangeEnd = DateHelper.format(from.getTime());
        ranges.add(new Range(rangeStart, true, rangeEnd, false));
    }
    
    return ranges;
}
 
源代码15 项目: ats-framework   文件: ResponseMatcher.java
protected boolean extractUserParameter(
                                        String description,
                                        String valueToMatch,
                                        String text ) throws XmlUtilitiesException {

    Logger log = Logger.getLogger(this.getClass());

    // apply the current user parameters
    valueToMatch = XmlUtilities.applyUserParameters(valueToMatch);

    //FIXME: Limited to one variable only
    int findex = valueToMatch.indexOf("${=") + "${=".length();
    String userParameterName = valueToMatch.substring(findex, valueToMatch.indexOf("}", findex));

    // TODO check the regex accuracy. currently escaped *, ., *, ^, -, ?  and $, {, }
    String patternToMatch = valueToMatch.replace("(", "\\(")
                                        .replace(")", "\\)")
                                        .replace("*", "\\*")
                                        .replace(".", "\\.")
                                        .replace("^", "\\^")
                                        .replace("-", "\\-")
                                        .replace("|", "\\|")
                                        .replace("?", "\\?")
                                        .replaceAll("\\$\\{\\=.*\\}", "(.*)");
    // escape $ { and }, and ${RANDOM} after we have replaced ${=...}
    patternToMatch = patternToMatch.replace("${RANDOM}", ".*")
                                   // match this place as value for the variable
                                   .replace("$", "\\$")
                                   .replace("{", "\\{")
                                   .replace("}", "\\}");

    Matcher matcher = Pattern.compile(patternToMatch).matcher(text);
    if (matcher.find() && matcher.groupCount() == 1) {
        String userParameterValue = matcher.group(1);
        if (log.isDebugEnabled()) {
            log.debug("Extracted new user parameter from " + description + ": '" + userParameterName
                      + "' = '" + userParameterValue + "'");
        }
        ThreadContext.setAttribute(userParameterName, userParameterValue);
        return true;
    } else {
        log.error("Could not extract the expected user parameter '" + userParameterName + "' from "
                  + text + " for " + toString());
        return false;
    }
}
 
源代码16 项目: ats-framework   文件: RestClient.java
private void constructInvocationBuilder( String descriptionToken,
                                         boolean suppressHttpComplianceValidation ) {

    constructUrl();

    boolean hasThirdPartyConnector = this.clientConfigurator.getConnectorProvider() != null;
    if (hasThirdPartyConnector) {

        boolean isApache = APACHE_CONNECTOR_CLASSNAME.equals(this.clientConfigurator.getConnectorProvider()
                                                                                    .getClass()
                                                                                    .getName());

        if (isApache) {

            // configure wire logging
            Logger headersLogger = Logger.getLogger(APACHE_HTTP_HEADERS_LOGGER_NAME);
            Logger wireLogger = Logger.getLogger(APACHE_HTTP_WIRE_LOGGER_NAME);

            if (headersLogger.isDebugEnabled() || wireLogger.isDebugEnabled()) {
                if (!verbosityLevelMessageLogged) {
                    verbosityLevelMessageLogged = true;
                    log.info("Rest client's verbose mode will not be applied because "
                             + "either '" + APACHE_HTTP_HEADERS_LOGGER_NAME + "' or '"
                             + APACHE_HTTP_WIRE_LOGGER_NAME
                             + "' Log4J logger is set to DEBUG or greater LOG level. "
                             + "Headers " + (wireLogger.isDebugEnabled()
                                                                         ? "and body"
                                                                         : "")
                             + " (for both request and response) will be logged");
                }
            } else {
                if ( (this.debugLevel & RESTDebugLevel.ALL) == RESTDebugLevel.ALL) {
                    headersLogger.setLevel(Level.OFF);
                    wireLogger.setLevel(Level.DEBUG);
                } else if ( (this.debugLevel & RESTDebugLevel.BODY) == RESTDebugLevel.BODY) {
                    headersLogger.setLevel(Level.OFF);
                    wireLogger.setLevel(Level.OFF);
                    if (!bodyOnlyDebugLevelMessageLogged) {
                        bodyOnlyDebugLevelMessageLogged = true;
                        log.info("Debug level is set to BODY only. "
                                 + "Both '" + APACHE_HTTP_HEADERS_LOGGER_NAME + "' and '"
                                 + APACHE_HTTP_WIRE_LOGGER_NAME + "' Log4J loggers will be disabled.");
                    }
                } else if ( (this.debugLevel & RESTDebugLevel.HEADERS) == RESTDebugLevel.HEADERS) {
                    headersLogger.setLevel(Level.DEBUG);
                    wireLogger.setLevel(Level.OFF);
                } else if ( (this.debugLevel & RESTDebugLevel.TARGET_URI) == RESTDebugLevel.TARGET_URI) {
                    headersLogger.setLevel(Level.OFF);
                    wireLogger.setLevel(Level.OFF);
                } else if ( (this.debugLevel & RESTDebugLevel.NONE) == RESTDebugLevel.NONE) {
                    headersLogger.setLevel(Level.OFF);
                    wireLogger.setLevel(Level.OFF);
                }
            }

            constructApacheConnectorInvocationBuilder(descriptionToken,
                                                      suppressHttpComplianceValidation);
        } else {
            constructThirdPartyConnectorInvocationBuilder(descriptionToken,
                                                          suppressHttpComplianceValidation);
        }

    } else {

        constructHttpUrlConnectionInvocationBuilder(descriptionToken,
                                                    suppressHttpComplianceValidation);
    }
}
 
源代码17 项目: serianalyzer   文件: Serianalyzer.java
/**
 * @param method
 * @throws SerianalyzerException
 */
private void doCheckMethod ( MethodReference methodReference ) throws SerianalyzerException {

    Logger cl = Verbose.getPerMethodLogger(methodReference);

    if ( cl.isTraceEnabled() ) {
        cl.trace(String.format("Checking reference %s", methodReference)); //$NON-NLS-1$
    }

    long currentTimeMillis = System.currentTimeMillis();
    if ( currentTimeMillis - this.lastOutput > OUTPUT_EVERY ) {
        log.info("Currently to check " + this.getState().getToCheck().size() + " known " + this.getState().countAllKnown()); //$NON-NLS-1$ //$NON-NLS-2$
        log.info("Sample " + methodReference); //$NON-NLS-1$
        this.lastOutput = currentTimeMillis;
    }

    try ( InputStream data = this.input.getClassData(methodReference.getTypeNameString()) ) {
        if ( data == null ) {
            cl.error("No class data for " + methodReference.getTypeNameString()); //$NON-NLS-1$
            return;
        }

        if ( this.input.getConfig().isWhitelisted(methodReference) ) {
            if ( cl.isDebugEnabled() ) {
                cl.debug("Is whitelisted " + methodReference); //$NON-NLS-1$
            }
            return;
        }

        short flags = this.getIndex().getClassByName(methodReference.getTypeName()).flags();
        if ( !methodReference.isStatic() && ( Modifier.isInterface(flags) || Modifier.isAbstract(flags) ) ) {
            log.debug("Resolved an interface/abstract class in non static call " + methodReference); //$NON-NLS-1$
        }

        ClassReader cr = new ClassReader(data);
        SerianalyzerClassMethodVisitor visitor = new SerianalyzerClassMethodVisitor(this, methodReference, methodReference.getTypeName());
        cr.accept(visitor, 0);

        Set<MethodReference> callers = this.state.getMethodCallers().get(methodReference.comparable());

        if ( !visitor.isFound() ) {
            if ( cl.isTraceEnabled() ) {
                cl.trace("Not found " + methodReference); //$NON-NLS-1$
            }

            boolean found = doCheckInSuperClasses(methodReference, cl, callers);

            if ( !found ) {
                cl.debug("Method not found in superclasses " + methodReference); //$NON-NLS-1$

                found = doCheckInInterfaces(methodReference, cl, callers);

                if ( !found && !methodReference.getTypeNameString().startsWith("java.lang.invoke.") ) { //$NON-NLS-1$
                    MethodReference cmp = methodReference.comparable();
                    if ( this.notFound.add(cmp) ) {
                        cl.warn("Method not found " + methodReference); //$NON-NLS-1$
                    }
                }
            }

        }
    }
    catch ( IOException e ) {
        log.error("Failed to read class " + methodReference.getTypeName()); //$NON-NLS-1$
    }
}
 
源代码18 项目: serianalyzer   文件: Serianalyzer.java
/**
 * @param methodReference
 * @param cl
 * @param callers
 * @return
 * @throws IOException
 */
private boolean doCheckInSuperClasses ( MethodReference methodReference, Logger cl, Set<MethodReference> callers ) throws IOException {
    DotName dn = methodReference.getTypeName();
    ClassInfo ci = this.input.getIndex().getClassByName(dn);
    do {
        if ( ci == null || "java.lang.Object".equals(dn.toString()) ) { //$NON-NLS-1$
            break;
        }

        DotName superName;
        if ( ci.superName() == null ) {
            superName = DotName.createSimple("java.lang.Object"); //$NON-NLS-1$
        }
        else {
            superName = ci.superName();
        }

        if ( "java.lang.Object".equals(superName.toString()) && TypeUtil.isObjectMethod(methodReference) ) { //$NON-NLS-1$
            return true;
        }

        ci = this.input.getIndex().getClassByName(superName);
        if ( ci == null ) {
            log.error("Failed to find super class " + superName); //$NON-NLS-1$
            return false;
        }

        MethodReference superRef = methodReference.adaptToType(superName);
        if ( TypeUtil.implementsMethod(methodReference, ci) && doCheckClassInternal(cl, methodReference, superRef) ) {
            this.state.traceCalls(superRef, callers);
            return true;
        }

        if ( cl.isDebugEnabled() ) {
            cl.debug("Failed to find in " + superName); //$NON-NLS-1$
        }
        dn = superName;
    }
    while ( true );
    return false;
}
 
源代码19 项目: spliceengine   文件: SpliceLogUtils.java
public static void debug(Logger logger, String message,Throwable t){
    if(logger.isDebugEnabled())logger.debug(message,t);
}
 
源代码20 项目: spliceengine   文件: SpliceLogUtils.java
public static void debug(Logger logger, String messageFormat,Object...args){
	if(logger.isDebugEnabled())logger.debug(String.format(messageFormat,args));
}