jodd.log.Logger.warn()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(344)

本文整理了Java中jodd.log.Logger.warn()方法的一些代码示例,展示了Logger.warn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.warn()方法的具体详情如下:
包路径:jodd.log.Logger
类名称:Logger
方法名:warn

Logger.warn介绍

[英]Logs a message at WARN level.
[中]以警告级别记录消息。

代码示例

代码示例来源:origin: oblac/jodd

/**
 * Logs a message at WARN level.
 */
default void warn(final Supplier<String> messageSupplier) {
  if (isWarnEnabled()) {
    warn(messageSupplier.get());
  }
}

代码示例来源:origin: oblac/jodd

/**
 * Clears resource bundle caches.
 */
protected static void clearResourceBundleCache() {
  try {
    clearMap(ResourceBundle.class, null, "cacheList");
  } catch (Exception ex) {
    log.warn("Unable to clear resource bundle cache", ex);
  }
}

代码示例来源:origin: oblac/jodd

/**
 * Logs a message at WARN level.
 */
default void warn(final Supplier<String> messageSupplier, final Throwable throwable) {
  if (isWarnEnabled()) {
    warn(messageSupplier.get(), throwable);
  }
}

代码示例来源:origin: oblac/jodd

/**
 * Writes created class content to output folder for debugging purposes.
 */
protected void dumpClassInDebugFolder(final byte[] bytes) {
  File debugFolder = proxetta.getDebugFolder();
  if (debugFolder == null) {
    return;
  }
  if (!debugFolder.exists() || !debugFolder.isDirectory()) {
    log.warn("Invalid debug folder: " + debugFolder);
  }
  String fileName = proxyClassName;
  if (fileName == null) {
    fileName = "proxetta-" + System.currentTimeMillis();
  }
  fileName += ".class";
  File file = new File(debugFolder, fileName);
  try {
    FileUtil.writeBytes(file, bytes);
  } catch (IOException ioex) {
    log.warn("Error writing class as " + file, ioex);
  }
}

代码示例来源:origin: oblac/jodd

@Test
void testWarnWithThrowable() {
  //given
  throwable = mock(Throwable.class);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  //then
  verify(log).warn(LoggerConstants.WARN_MESSAGE, throwable);
}

代码示例来源:origin: oblac/jodd

@Test
void testWarnWithThrowable() {
  //given
  throwable = mock(Throwable.class);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  //then
  verify(log).warn(LoggerConstants.WARN_MESSAGE, throwable);
}

代码示例来源:origin: oblac/jodd

@Test
void testWarnWithThrowable() {
  //given
  throwable = mock(Throwable.class);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  //then
  verify(log).warn(LoggerConstants.WARN_MESSAGE, throwable);
}

代码示例来源:origin: oblac/jodd

@Test
void testWarnWithThrowable() {
  //given
  throwable = mock(Throwable.class);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  //then
  verify(log).log(java.util.logging.Level.WARNING, LoggerConstants.WARN_MESSAGE, throwable);
}

代码示例来源:origin: oblac/jodd

@Test
void testLogger() {
  PrintStream original = System.out;
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintStream ps = new PrintStream(baos);
  System.setOut(ps);
  LoggerFactory.setLoggerProvider(Slf4jLogger.PROVIDER);
  Logger log = LoggerFactory.getLogger("Foo");
  log.warn("123");
  System.out.flush();
  System.setOut(original);
  assertEquals(
    "WARN Foo " + this.getClass().getName() + " testLogger 51 - 123", baos.toString().trim());
}

代码示例来源:origin: oblac/jodd

/**
 * Resolves column db sql type and populates it in column descriptor if missing.
 */
protected void resolveColumnDbSqlType(final Connection connection, final DbEntityColumnDescriptor dec) {
  if (dec.dbSqlType != SqlType.DB_SQLTYPE_UNKNOWN) {
    return;
  }
  ResultSet rs = null;
  DbEntityDescriptor ded = dec.getDbEntityDescriptor();
  try {
    DatabaseMetaData dmd = connection.getMetaData();
    rs = dmd.getColumns(null, ded.getSchemaName(), ded.getTableName(), dec.getColumnName());
    if (rs.next()) {
      dec.dbSqlType = rs.getInt("DATA_TYPE");
    } else {
      dec.dbSqlType = SqlType.DB_SQLTYPE_NOT_AVAILABLE;
      if (log.isWarnEnabled()) {
        log.warn("Column SQL type not available: " + ded.toString() + '.' + dec.getColumnName());
      }
    }
  } catch (SQLException sex) {
    dec.dbSqlType = SqlType.DB_SQLTYPE_NOT_AVAILABLE;
    if (log.isWarnEnabled()) {
      log.warn("Column SQL type not resolved: " + ded.toString() + '.' + dec.getColumnName(), sex);
    }
  } finally {
    DbUtil.close(rs);
  }
}

代码示例来源:origin: oblac/jodd

@Test
void testLevel() {
  //when
  logger.trace(LoggerConstants.TRACE_MESSAGE);
  //then
  verify(log).trace(LoggerConstants.TRACE_MESSAGE);
  //when
  logger.debug(LoggerConstants.DEBUG_MESSAGE);
  //then
  verify(log).debug(LoggerConstants.DEBUG_MESSAGE);
  //when
  logger.info(LoggerConstants.INFO_MESSAGE);
  //then
  verify(log).info(LoggerConstants.INFO_MESSAGE);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE);
  //then
  verify(log).warn(LoggerConstants.WARN_MESSAGE);
  //when
  logger.error(LoggerConstants.ERROR_MESSAGE);
  //then
  verify(log).error(LoggerConstants.ERROR_MESSAGE);
}

代码示例来源:origin: oblac/jodd

@Test
void testThrowable() {
  //given
  throwable = mock(Throwable.class);
  setUpOutputStream();
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  //then
  output = outputStream.toString();
  assertTrue(output.contains(LoggerConstants.WARN_MESSAGE));
  verify(throwable).printStackTrace(System.out);
  //setup
  throwable = mock(Throwable.class);
  //when
  logger.error(LoggerConstants.ERROR_MESSAGE, throwable);
  //then
  output = outputStream.toString();
  assertTrue(output.contains(LoggerConstants.ERROR));
  verify(throwable).printStackTrace(System.out);
}

代码示例来源:origin: oblac/jodd

@Test
void testLevel() {
  //when
  logger.trace(LoggerConstants.TRACE_MESSAGE);
  //then
  verify(log).log(java.util.logging.Level.FINER, LoggerConstants.TRACE_MESSAGE);
  //when
  logger.debug(LoggerConstants.DEBUG_MESSAGE);
  //then
  verify(log).log(java.util.logging.Level.FINE, LoggerConstants.DEBUG_MESSAGE);
  //when
  logger.info(LoggerConstants.INFO_MESSAGE);
  //then
  verify(log).log(java.util.logging.Level.INFO, LoggerConstants.INFO_MESSAGE);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE);
  //then
  verify(log).log(java.util.logging.Level.WARNING, LoggerConstants.WARN_MESSAGE);
  //when
  logger.error(LoggerConstants.ERROR_MESSAGE);
  //then
  verify(log).log(java.util.logging.Level.SEVERE, LoggerConstants.ERROR_MESSAGE);
}

代码示例来源:origin: oblac/jodd

@Test
void testLevel() {
  //when
  logger.trace(LoggerConstants.TRACE_MESSAGE);
  //then
  verify(log).trace(LoggerConstants.TRACE_MESSAGE);
  //when
  logger.debug(LoggerConstants.DEBUG_MESSAGE);
  //then
  verify(log).debug(LoggerConstants.DEBUG_MESSAGE);
  //when
  logger.info(LoggerConstants.INFO_MESSAGE);
  //then
  verify(log).info(LoggerConstants.INFO_MESSAGE);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE);
  //then
  verify(log).warn(LoggerConstants.WARN_MESSAGE);
  //when
  logger.error(LoggerConstants.ERROR_MESSAGE);
  //then
  verify(log).error(LoggerConstants.ERROR_MESSAGE);
}

代码示例来源:origin: oblac/jodd

@Test
void testLevel() {
  //when
  logger.trace(LoggerConstants.TRACE_MESSAGE);
  //then
  verify(log).trace(LoggerConstants.TRACE_MESSAGE);
  //when
  logger.debug(LoggerConstants.DEBUG_MESSAGE);
  //then
  verify(log).debug(LoggerConstants.DEBUG_MESSAGE);
  //when
  logger.info(LoggerConstants.INFO_MESSAGE);
  //then
  verify(log).info(LoggerConstants.INFO_MESSAGE);
  //when
  logger.warn(LoggerConstants.WARN_MESSAGE);
  //then
  verify(log).warn(LoggerConstants.WARN_MESSAGE);
  //when
  logger.error(LoggerConstants.ERROR_MESSAGE);
  //then
  verify(log).error(LoggerConstants.ERROR_MESSAGE);
}

代码示例来源:origin: oblac/jodd

/**
 * Creates new DbOom.
 */
public DbOom(
    final ConnectionProvider connectionProvider,
    final DbSessionProvider dbSessionProvider,
    final QueryMap queryMap) {
  this.connectionProvider = connectionProvider;
  this.dbSessionProvider = dbSessionProvider;
  this.queryMap = queryMap;
  this.dbOomConfig = new DbOomConfig();
  this.dbQueryConfig = new DbQueryConfig();
  this.dbEntityManager = new DbEntityManager(dbOomConfig);
  this.dbEntitySql = new DbEntitySql(this);
  // static init
  if (defaultDbOom == null) {
    log.info("Default DbOom is created.");
    defaultDbOom = this;
  }
  else {
    log.warn("Multiple DbOom detected.");
    defaultDbOom = null;
  }
}

代码示例来源:origin: oblac/jodd

@Test
void testLog() {
  //given
  throwable = mock(Throwable.class);
  //when
  //The below methods are no op methods in actual implementations.
  //so we will not be able to verify anything
  logger.log(Level.DEBUG, name);
  logger.trace(name);
  logger.debug(name);
  logger.info(name);
  logger.warn(name);
  logger.warn(name, throwable);
  logger.error(name);
  logger.error(name, throwable);
}

代码示例来源:origin: oblac/jodd

logger.warn(LoggerConstants.WARN_MESSAGE);

代码示例来源:origin: oblac/jodd

log.warn(createMixingMessage(targetBeanDefinition, refBeanDefinition));

代码示例来源:origin: oblac/jodd

/**
 * Authenticate user and start user session.
 */
protected JsonResult login() {
  T authToken;
  authToken = loginViaBasicAuth(servletRequest);
  if (authToken == null) {
    authToken = loginViaRequestParams(servletRequest);
  }
  if (authToken == null) {
    log.warn("Login failed.");
    return JsonResult.of(HttpStatus.error401().unauthorized("Login failed."));
  }
  log.info("login OK!");
  final UserSession<T> userSession = new UserSession<>(authToken, userAuth.tokenValue(authToken));
  userSession.start(servletRequest, servletResponse);
  // return token
  return tokenAsJson(authToken);
}

相关文章