本文整理了Java中jodd.log.Logger.isDebugEnabled()
方法的一些代码示例,展示了Logger.isDebugEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isDebugEnabled()
方法的具体详情如下:
包路径:jodd.log.Logger
类名称:Logger
方法名:isDebugEnabled
[英]Returns true
if DEBUG level is enabled.
[中]如果启用调试级别,则返回true
。
代码示例来源:origin: oblac/jodd
/**
* Logs a message at DEBUG level.
*/
default void debug(final Supplier<String> messageSupplier) {
if (isDebugEnabled()) {
debug(messageSupplier.get());
}
}
代码示例来源:origin: oblac/jodd
/**
* Saves Locale to HTTP session.
*/
public static void setSessionLocale(final HttpSession session, final String localeCode) {
if (log.isDebugEnabled()) {
log.debug("Locale stored to session: " + localeCode);
}
Locale locale = Locale.forLanguageTag(localeCode);
session.setAttribute(SESSION_LOCALE_ATTR, locale);
}
代码示例来源:origin: oblac/jodd
/**
* Sets bundle name for provided servlet request.
*/
public static void setRequestBundleName(final ServletRequest request, final String bundleName) {
if (log.isDebugEnabled()) {
log.debug("Bundle name for this request: " + bundleName);
}
request.setAttribute(REQUEST_BUNDLE_NAME_ATTR, bundleName);
}
代码示例来源:origin: oblac/jodd
/**
* Returns <code>true</code> if target exists.
*/
protected boolean targetExists(final ActionRequest actionRequest, final String target) {
if (log.isDebugEnabled()) {
log.debug("target check: " + target);
}
final ServletContext servletContext = actionRequest.getHttpServletRequest().getServletContext();
try {
return servletContext.getResource(target) != null;
} catch (MalformedURLException ignore) {
return false;
}
}
代码示例来源:origin: oblac/jodd
/**
* Locates gzipped version of bundle file. If gzip file
* does not exist, it will be created.
*/
public File lookupGzipBundleFile(final File file) throws IOException {
String path = file.getPath() + ZipUtil.GZIP_EXT;
File gzipFile = new File(path);
if (!gzipFile.exists()) {
if (log.isDebugEnabled()) {
log.debug("gzip bundle to " + path);
}
ZipUtil.gzip(file);
}
return gzipFile;
}
代码示例来源:origin: oblac/jodd
/**
* Creates new Petite container using {@link PetiteContainer provided configuration}.
*/
public PetiteContainer(final PetiteConfig config) {
super(config);
scopedProxyManager = new ScopedProxyManager();
if (log.isDebugEnabled()) {
log.debug("Petite container created");
}
}
代码示例来源:origin: oblac/jodd
@Override
protected boolean processActionPath(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse, final String actionPath) throws IOException {
String bundlePath = '/' + bundlesManager.getStaplerPath() + '/';
if (!actionPath.startsWith(bundlePath)) {
return false;
}
String bundleId = actionPath.substring(bundlePath.length());
File file = bundlesManager.lookupBundleFile(bundleId);
if (log.isDebugEnabled()) {
log.debug("bundle: " + bundleId);
}
int ndx = bundleId.lastIndexOf('.');
String extension = bundleId.substring(ndx + 1);
String contentType = MimeTypes.getMimeType(extension);
servletResponse.setContentType(contentType);
if (useGzip && ServletUtil.isGzipSupported(servletRequest)) {
file = bundlesManager.lookupGzipBundleFile(file);
servletResponse.setHeader("Content-Encoding", "gzip");
}
if (!file.exists()) {
throw new IOException("bundle not found: " + bundleId);
}
servletResponse.setHeader("Content-Length", String.valueOf(file.length()));
servletResponse.setHeader("Last-Modified", TimeUtil.formatHttpDate(file.lastModified()));
if (cacheMaxAge > 0) {
servletResponse.setHeader("Cache-Control", "max-age=" + cacheMaxAge);
}
sendBundleFile(servletResponse, file);
return true;
}
代码示例来源:origin: oblac/jodd
public DbCallResult executeCall() {
start = System.currentTimeMillis();
init();
if (log.isDebugEnabled()) {
log.debug("Calling statement: " + getQueryString());
}
try {
callableStatement.execute();
} catch (SQLException sex) {
DbUtil.close(callableStatement);
throw new DbSqlException(this, "Query execution failed", sex);
}
elapsed = System.currentTimeMillis() - start;
if (log.isDebugEnabled()) {
log.debug("execution time: " + elapsed + "ms");
}
return new DbCallResult(query, callableStatement);
}
代码示例来源:origin: oblac/jodd
/**
* Creates new transaction. Should be invoked by {@link jodd.jtx.JtxTransactionManager}.
* If transaction is set as <code>active</code>, it will be actually created, meaning
* that it is the first transaction on this connection i.e. in this session.
* If transaction is not <code>active</code>, transaction object will be created,
* but the real transaction not, and it is expected that one is already created before.
*
* @param txManager jtx manager
* @param mode transaction mode
* @param scope transaction live scope within the other transaction requests are ignored
* @param active if <code>true</code> it is an active transaction, otherwise it's not
*/
public JtxTransaction(final JtxTransactionManager txManager, final JtxTransactionMode mode, final Object scope, final boolean active) {
this.txManager = txManager;
this.mode = mode;
this.scope = scope;
this.resources = new HashSet<>();
this.deadline = mode.getTransactionTimeout() == DEFAULT_TIMEOUT ?
DEFAULT_TIMEOUT :
System.currentTimeMillis() + (mode.getTransactionTimeout() * 1000L);
this.status = active ? STATUS_ACTIVE : STATUS_NO_TRANSACTION;
this.startAsActive = active;
txManager.associateTransaction(this);
if (log.isDebugEnabled()) {
log.debug("New JTX {status:" + this.status + ", mode:" + this.mode + '}');
}
}
代码示例来源:origin: oblac/jodd
/**
* Registers new action result instance. If action result of the same class is already
* registered, registration will be skipped. If result for the same result type or
* same target class exist, it will be replaced! However, default Jodd results will
* <i>never</i> replace other results. After the registration, results are initialized.
*/
protected ActionResult register(final ActionResult result) {
Class<? extends ActionResult> actionResultClass = result.getClass();
// check existing
ActionResult existingResult = allResults.get(actionResultClass);
if (existingResult != null) {
if (log.isDebugEnabled()) {
log.debug("ActionResult already registered: " + actionResultClass);
}
return existingResult;
}
allResults.put(actionResultClass, result);
// + init
initializeResult(result);
return result;
}
代码示例来源:origin: oblac/jodd
if (log.isDebugEnabled()) {
log.debug("Executing prepared count: " + getQueryString());
if (log.isDebugEnabled()) {
log.debug("execution time: " + elapsed + "ms");
代码示例来源:origin: oblac/jodd
if (log.isDebugEnabled()) {
log.debug("Executing statement: " + getQueryString());
if (log.isDebugEnabled()) {
log.debug("execution time: " + elapsed + "ms");
代码示例来源:origin: oblac/jodd
/**
* Returns byte array of created class.
*/
public byte[] create() {
process();
byte[] result = toByteArray();
dumpClassInDebugFolder(result);
if ((!proxetta.isForced()) && (!isProxyApplied())) {
if (log.isDebugEnabled()) {
log.debug("Proxy not applied: " + StringUtil.toSafeString(targetClassName));
}
return null;
}
if (log.isDebugEnabled()) {
log.debug("Proxy created " + StringUtil.toSafeString(targetClassName));
}
return result;
}
代码示例来源:origin: oblac/jodd
/**
* Registers just type and entity names. Enough for most usages.
*/
public <E> DbEntityDescriptor<E> registerType(final Class<E> type) {
DbEntityDescriptor<E> ded = createDbEntityDescriptor(type);
DbEntityDescriptor<E> existing = descriptorsMap.put(type, ded);
if (log.isDebugEnabled()) {
log.debug("Register " + type.getName() + " as " + ded.getTableName());
}
if (existing != null) {
if (ded.getType() == type) {
return ded;
}
throw new DbOomException("Type already registered: " + existing.getType());
}
existing = entityNamesMap.put(ded.getEntityName(), ded);
if (existing != null) {
throw new DbOomException("Name '" + ded.getEntityName() + "' already mapped to an entity: " + existing.getType());
}
return ded;
}
代码示例来源:origin: oblac/jodd
/**
* Reads the target and creates destination class.
*/
protected void process() {
if (targetInputStream == null) {
throw new ProxettaException("Target missing: " + targetClassName);
}
// create class reader
final ClassReader classReader;
try {
classReader = new ClassReader(targetInputStream);
} catch (IOException ioex) {
throw new ProxettaException("Error reading class input stream", ioex);
}
// reads information
final TargetClassInfoReader targetClassInfoReader = new TargetClassInfoReader(proxetta.getClassLoader());
classReader.accept(targetClassInfoReader, 0);
this.destClassWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
// create proxy
if (log.isDebugEnabled()) {
log.debug("processing: " + classReader.getClassName());
}
WorkData wd = process(classReader, targetClassInfoReader);
// store important data
proxyApplied = wd.proxyApplied;
proxyClassName = wd.thisReference.replace('/', '.');
}
代码示例来源:origin: oblac/jodd
if (log.isDebugEnabled()) {
if (doCommit) {
log.debug("Commit JTX");
代码示例来源:origin: oblac/jodd
/**
* Requests transaction with specified {@link JtxTransactionMode mode}.
* Depending on propagation behavior, it will return either <b>existing</b> or <b>new</b> transaction.
* Only one transaction can be opened over one scope.
* The exception may be thrown indicating propagation mismatch.
*/
public JtxTransaction requestTransaction(final JtxTransactionMode mode, final Object scope) {
if (log.isDebugEnabled()) {
log.debug("Requesting TX " + mode.toString());
}
JtxTransaction currentTx = getTransaction();
if (!isNewTxScope(currentTx, scope)) {
return currentTx;
}
switch (mode.getPropagationBehavior()) {
case PROPAGATION_REQUIRED: return propRequired(currentTx, mode, scope);
case PROPAGATION_SUPPORTS: return propSupports(currentTx, mode, scope);
case PROPAGATION_MANDATORY: return propMandatory(currentTx, mode, scope);
case PROPAGATION_REQUIRES_NEW: return propRequiresNew(currentTx, mode, scope);
case PROPAGATION_NOT_SUPPORTED: return propNotSupported(currentTx, mode, scope);
case PROPAGATION_NEVER: return propNever(currentTx, mode, scope);
}
throw new JtxException("Invalid TX propagation value: " + mode.getPropagationBehavior().value());
}
代码示例来源:origin: oblac/jodd
@Test
void testIsLevelEnabled() {
// Loggers does not provide any API to enable levels.
// Instead we need to use log/level(trace/debug etc) API to log information into corresponding level
assertFalse(logger.isTraceEnabled());
assertFalse(logger.isDebugEnabled());
assertFalse(logger.isInfoEnabled());
assertFalse(logger.isWarnEnabled());
assertFalse(logger.isErrorEnabled());
}
代码示例来源:origin: oblac/jodd
if (log.isDebugEnabled()) {
log.debug("LagartoDom tree created in " + rootNode.getElapsedTime() + " ms");
代码示例来源:origin: oblac/jodd
@Override
@Test
void testIsLevelEnabled() {
//when
initializeLogFactoryAndLogger(Logger.Level.DEBUG);
//then
assertTrue(logger.isDebugEnabled());
//when
initializeLogFactoryAndLogger(Logger.Level.ERROR);
//then
assertTrue(logger.isErrorEnabled());
//when
initializeLogFactoryAndLogger(Logger.Level.INFO);
//then
assertTrue(logger.isInfoEnabled());
//when
initializeLogFactoryAndLogger(Logger.Level.TRACE);
//then
assertTrue(logger.isTraceEnabled());
//when
initializeLogFactoryAndLogger(Logger.Level.WARN);
//then
assertTrue(logger.isWarnEnabled());
}
内容来源于网络,如有侵权,请联系作者删除!