Java Code Examples for org.slf4j.Logger.isDebugEnabled()

The following are Jave code examples for showing how to use isDebugEnabled() of the org.slf4j.Logger 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: OftenPorter   File: PortExecutor.java   View Source Code Vote up 6 votes
private void responseObject(WObject wObject, PorterOfFun porterOfFun, Object object, boolean nullClose)
{
    if (object != null)
    {
        Logger LOGGER = logger(wObject);

        if (object != null && object instanceof JResponse && ((JResponse) object).isNotSuccess())
        {
            wObject.getResponse().toErr();
            if (LOGGER.isDebugEnabled())
            {
                LOGGER.debug("{}:{}", wObject.url(), object);

            } else if (LOGGER.isInfoEnabled())
            {
                LOGGER.info("{}:{}", wObject.url(), object);
            }
        }
        doFinalWrite(wObject, porterOfFun, object);
        close(wObject);
    } else if (nullClose)
    {
        close(wObject);
    }
}
 
Example 2
Project: easyhbase   File: LoggerUtils.java   View Source Code Vote up 6 votes
public static int getLoggerLevel(Logger logger) {
    if (logger == null) {
        throw new NullPointerException("logger must not be null");
    }
    if (logger.isTraceEnabled()) {
        return TRACE_LEVEL;
    }
    if (logger.isDebugEnabled()) {
        return DEBUG_LEVEL;
    }
    if (logger.isInfoEnabled()) {
        return INFO_LEVEL;
    }
    if (logger.isWarnEnabled()) {
        return WARN_LEVEL;
    }
    if (logger.isErrorEnabled()) {
        return ERROR_LEVEL;
    }
    return DISABLE_LEVEL;
}
 
Example 3
Project: MantaroRPG   File: SimpleLogToSLF4JAdapter.java   View Source Code Vote up 6 votes
@Override
public void onLog(SimpleLog simpleLog, SimpleLog.Level logLevel, Object message) {
	Logger log = convert(simpleLog);
	switch (logLevel) {
		case TRACE:
			if (log.isTraceEnabled()) {
				log.trace(message.toString());
			}
			break;
		case DEBUG:
			if (log.isDebugEnabled()) {
				log.debug(message.toString());
			}
			break;
		case INFO:
			log.info(message.toString());
			break;
		case WARNING:
			log.warn(message.toString());
			break;
		case FATAL:
			log.error(message.toString());
			break;
	}
}
 
Example 4
Project: hekate   File: NettyClientHandler.java   View Source Code Vote up 6 votes
public NettyClientHandler(String id, int epoch, String protocol, int affinity, T login, Integer connTimeout, long idleTimeout,
    Logger log, NettyMetricsSink metrics, NettyClient<T> client, NetworkClientCallback<T> callback) {
    this.log = log;
    this.id = id;
    this.epoch = epoch;
    this.protocol = protocol;
    this.affinity = affinity;
    this.login = login;
    this.idleTimeout = idleTimeout;
    this.connTimeout = connTimeout;
    this.metrics = metrics;
    this.client = client;
    this.callback = callback;

    this.debug = log.isDebugEnabled();
    this.trace = log.isTraceEnabled();

    hbOnFlush = future -> {
        hbFlushed = true;

        if (!future.isSuccess() && future.channel().isOpen()) {
            future.channel().pipeline().fireExceptionCaught(future.cause());
        }
    };
}
 
Example 5
Project: slf4j-lambda   File: LambdaLoggerUtils.java   View Source Code Vote up 5 votes
/**
 * check if log level is enabled in the underlying logger
 *
 * @param underlyingLogger real Slf4j Logger implementation
 * @param logLevel log level
 * @param marker marker
 * @return true if log level is enabled or false.
 */
public static boolean isLogLevelEnabled(Logger underlyingLogger, Level logLevel, Marker marker) {
    switch (logLevel) {
        case TRACE:
            if (marker == null) {
                return underlyingLogger.isTraceEnabled();
            }
            return underlyingLogger.isTraceEnabled(marker);
        case DEBUG:
            if (marker == null) {
                return underlyingLogger.isDebugEnabled();
            }
            return underlyingLogger.isDebugEnabled(marker);
        case INFO:
            if (marker == null) {
                return underlyingLogger.isInfoEnabled();
            }
            return underlyingLogger.isInfoEnabled(marker);
        case WARN:
            if (marker == null) {
                return underlyingLogger.isWarnEnabled();
            }
            return underlyingLogger.isWarnEnabled(marker);
        case ERROR:
            if (marker == null) {
                return underlyingLogger.isErrorEnabled();
            }
            return underlyingLogger.isErrorEnabled(marker);
        default:
            break;
    }
    return false;
}
 
Example 6
Project: ait-platform   File: AitLogger.java   View Source Code Vote up 5 votes
/**
 * debug
 * @param logger
 * @param message
 * @param params
 */

public static void debug(Logger logger, String message, Object... params) {
	
	if (logger.isDebugEnabled()) {
		logger.debug(message, params);
	}
}
 
Example 7
Project: asura   File: DBSemaphore.java   View Source Code Vote up 5 votes
/**
 * Grants a lock on the identified resource to the calling thread (blocking
 * until it is available).
 * 
 * @return true if the lock was obtained.
 */
public boolean obtainLock(Connection conn, String lockName)
    throws LockException {

    lockName = lockName.intern();

    Logger log = getLog();
    
    if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' is desired by: "
                    + Thread.currentThread().getName());
    }
    if (!isLockOwner(conn, lockName)) {

        executeSQL(conn, lockName, expandedSQL);
        
        if(log.isDebugEnabled()) {
            log.debug(
                "Lock '" + lockName + "' given to: "
                        + Thread.currentThread().getName());
        }
        getThreadLocks().add(lockName);
        //getThreadLocksObtainer().put(lockName, new
        // Exception("Obtainer..."));
    } else if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' Is already owned by: "
                    + Thread.currentThread().getName());
    }

    return true;
}
 
Example 8
Project: hekate   File: NettyClientDeferHandler.java   View Source Code Vote up 5 votes
public NettyClientDeferHandler(String id, Logger log) {
    this.id = id;
    this.log = log;

    this.debug = log.isDebugEnabled();
    this.trace = log.isTraceEnabled();
}
 
Example 9
Project: openhab-tado   File: TadoApiClientFactory.java   View Source Code Vote up 5 votes
private void configureLogging(ApiClient apiClient) {
    // Add logging interceptor to HTTP Client if Debug is enabled. Make it configurable?
    Logger logger = LoggerFactory.getLogger(PUBLICApi.class);
    if (logger.isDebugEnabled()) {
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
            @Override
            public void log(String msg) {
                logger.debug(msg);
            }
        });
        loggingInterceptor.setLevel(Level.BODY);
        apiClient.getOkBuilder().addNetworkInterceptor(loggingInterceptor);
    }
}
 
Example 10
Project: rockscript   File: ServerRequest.java   View Source Code Vote up 5 votes
@Override
public void logBodyString(String bodyString, Logger log) {
  if (log.isDebugEnabled()) {
    if (bodyString!=null) {
      BufferedReader reader = new BufferedReader(new StringReader(bodyString));
      reader.lines().forEach(line->log.debug("  "+line));
    } else {
      log.debug("  ---body-is-null---");
    }
  }
}
 
Example 11
Project: mzzb-server   File: AutoRunConfig.java   View Source Code Vote up 5 votes
private void fetchAmazonDiscsData(int retry) {
    Logger logger = LoggerFactory.getLogger(AutoRunConfig.class);
    if (retry == 0) {
        if (logger.isWarnEnabled()) {
            logger.warn("fetching amazon discs data failed");
        }
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("fetching amazon discs data ({})", retry);
        }
        try {
            amazonDiscsSpider.fetch();
        } catch (IOException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("fetching amazon discs data throw an error", e);
            }
            if (retry > 0) {
                fetchSakuraSpeedData(retry - 1);
            } else {
                return;
            }
        }
        if (logger.isInfoEnabled()) {
            logger.info("fetched amazon discs data ({})", retry);
        }
    }
}
 
Example 12
Project: QDrill   File: DefaultSqlHandler.java   View Source Code Vote up 4 votes
protected static void log(final String name, final RelNode node, final Logger logger) {
  if (logger.isDebugEnabled()) {
    logger.debug(name + " : \n" + RelOptUtil.toString(node, SqlExplainLevel.ALL_ATTRIBUTES));
  }
}
 
Example 13
Project: asura   File: SimpleSemaphore.java   View Source Code Vote up 4 votes
/**
 * Grants a lock on the identified resource to the calling thread (blocking
 * until it is available).
 * 
 * @return true if the lock was obtained.
 */
public synchronized boolean obtainLock(Connection conn, String lockName) {

    lockName = lockName.intern();

    Logger log = getLog();

    if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' is desired by: "
                    + Thread.currentThread().getName());
    }

    if (!isLockOwner(conn, lockName)) {
        if(log.isDebugEnabled()) {
            log.debug(
                "Lock '" + lockName + "' is being obtained: "
                        + Thread.currentThread().getName());
        }
        while (locks.contains(lockName)) {
            try {
                this.wait();
            } catch (InterruptedException ie) {
                if(log.isDebugEnabled()) {
                    log.debug(
                        "Lock '" + lockName + "' was not obtained by: "
                                + Thread.currentThread().getName());
                }
            }
        }

        if(log.isDebugEnabled()) {
            log.debug(
                "Lock '" + lockName + "' given to: "
                        + Thread.currentThread().getName());
        }
        getThreadLocks().add(lockName);
        locks.add(lockName);
    } else if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' already owned by: "
                    + Thread.currentThread().getName()
                    + " -- but not owner!",
            new Exception("stack-trace of wrongful returner"));
    }

    return true;
}
 
Example 14
Project: asura   File: JTANonClusteredSemaphore.java   View Source Code Vote up 4 votes
/**
 * Grants a lock on the identified resource to the calling thread (blocking
 * until it is available).
 * 
 * @return true if the lock was obtained.
 */
public synchronized boolean obtainLock(Connection conn, String lockName) throws LockException {

    lockName = lockName.intern();

    Logger log = getLog();

    if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' is desired by: "
                    + Thread.currentThread().getName());
    }

    if (!isLockOwner(conn, lockName)) {
        if(log.isDebugEnabled()) {
            log.debug(
                "Lock '" + lockName + "' is being obtained: "
                        + Thread.currentThread().getName());
        }
        
        while (locks.contains(lockName)) {
            try {
                this.wait();
            } catch (InterruptedException ie) {
                if(log.isDebugEnabled()) {
                    log.debug(
                        "Lock '" + lockName + "' was not obtained by: "
                                + Thread.currentThread().getName());
                }
            }
        }

        // If we are in a transaction, register a callback to actually release
        // the lock when the transaction completes
        Transaction t = getTransaction();
        if (t != null) {
            try {
                t.registerSynchronization(new SemaphoreSynchronization(lockName));
            } catch (Exception e) {
                throw new LockException("Failed to register semaphore with Transaction.", e);
            }
        }
        
        if(log.isDebugEnabled()) {
            log.debug(
                "Lock '" + lockName + "' given to: "
                        + Thread.currentThread().getName());
        }
        
        
        getThreadLocks().add(lockName);
        locks.add(lockName);
    } else if(log.isDebugEnabled()) {
        log.debug(
            "Lock '" + lockName + "' already owned by: "
                    + Thread.currentThread().getName()
                    + " -- but not owner!",
            new Exception("stack-trace of wrongful returner"));
    }

    return true;
}
 
Example 15
Project: QDrill   File: DefaultSqlHandler.java   View Source Code Vote up 4 votes
protected void log(final String name, final PhysicalPlan plan, final Logger logger) throws JsonProcessingException {
  if (logger.isDebugEnabled()) {
    String planText = plan.unparse(context.getConfig().getMapper().writer());
    logger.debug(name + " : \n" + planText);
  }
}
 
Example 16
Project: centraldogma   File: Polyfills.java   View Source Code Vote up 4 votes
public static void consoleDebug(Logger logger, ScriptObjectMirror args) {
    if (logger.isDebugEnabled()) {
        logger.debug(logMessage(args));
    }
}
 
Example 17
Project: happylifeplat-tcc   File: LogUtil.java   View Source Code Vote up 4 votes
public static void debug(Logger logger, Supplier<Object> supplier) {
    if (logger.isDebugEnabled()) {
        logger.debug(Objects.toString(supplier.get()));
    }
}
 
Example 18
Project: dremio-oss   File: PrelTransformer.java   View Source Code Vote up 4 votes
protected static void log(final PlannerType plannerType, final PlannerPhase phase, final RelNode node, final Logger logger,
    Stopwatch watch) {
  if (logger.isDebugEnabled()) {
    log(plannerType.name() + ":" + phase.description, node, logger, watch);
  }
}
 
Example 19
Project: myth   File: LogUtil.java   View Source Code Vote up 4 votes
public static void debug(Logger logger, Supplier<Object> supplier) {
    if (logger.isDebugEnabled()) {
        logger.debug(Objects.toString(supplier.get()));
    }
}
 
Example 20
Project: happylifeplat-tcc   File: LogUtil.java   View Source Code Vote up 2 votes
/**
 * debug 打印日志
 *
 * @param logger   日志
 * @param format   日志信息
 * @param supplier supplier接口
 */
public static void debug(Logger logger, String format, Supplier<Object> supplier) {
    if (logger.isDebugEnabled()) {
        logger.debug(format, supplier.get());
    }
}