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

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

本文整理了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

  1. /**
  2. * Logs a message at WARN level.
  3. */
  4. default void warn(final Supplier<String> messageSupplier) {
  5. if (isWarnEnabled()) {
  6. warn(messageSupplier.get());
  7. }
  8. }

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

  1. /**
  2. * Clears resource bundle caches.
  3. */
  4. protected static void clearResourceBundleCache() {
  5. try {
  6. clearMap(ResourceBundle.class, null, "cacheList");
  7. } catch (Exception ex) {
  8. log.warn("Unable to clear resource bundle cache", ex);
  9. }
  10. }

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

  1. /**
  2. * Logs a message at WARN level.
  3. */
  4. default void warn(final Supplier<String> messageSupplier, final Throwable throwable) {
  5. if (isWarnEnabled()) {
  6. warn(messageSupplier.get(), throwable);
  7. }
  8. }

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

  1. /**
  2. * Writes created class content to output folder for debugging purposes.
  3. */
  4. protected void dumpClassInDebugFolder(final byte[] bytes) {
  5. File debugFolder = proxetta.getDebugFolder();
  6. if (debugFolder == null) {
  7. return;
  8. }
  9. if (!debugFolder.exists() || !debugFolder.isDirectory()) {
  10. log.warn("Invalid debug folder: " + debugFolder);
  11. }
  12. String fileName = proxyClassName;
  13. if (fileName == null) {
  14. fileName = "proxetta-" + System.currentTimeMillis();
  15. }
  16. fileName += ".class";
  17. File file = new File(debugFolder, fileName);
  18. try {
  19. FileUtil.writeBytes(file, bytes);
  20. } catch (IOException ioex) {
  21. log.warn("Error writing class as " + file, ioex);
  22. }
  23. }

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

  1. @Test
  2. void testWarnWithThrowable() {
  3. //given
  4. throwable = mock(Throwable.class);
  5. //when
  6. logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  7. //then
  8. verify(log).warn(LoggerConstants.WARN_MESSAGE, throwable);
  9. }

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

  1. @Test
  2. void testWarnWithThrowable() {
  3. //given
  4. throwable = mock(Throwable.class);
  5. //when
  6. logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  7. //then
  8. verify(log).warn(LoggerConstants.WARN_MESSAGE, throwable);
  9. }

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

  1. @Test
  2. void testWarnWithThrowable() {
  3. //given
  4. throwable = mock(Throwable.class);
  5. //when
  6. logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  7. //then
  8. verify(log).warn(LoggerConstants.WARN_MESSAGE, throwable);
  9. }

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

  1. @Test
  2. void testWarnWithThrowable() {
  3. //given
  4. throwable = mock(Throwable.class);
  5. //when
  6. logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  7. //then
  8. verify(log).log(java.util.logging.Level.WARNING, LoggerConstants.WARN_MESSAGE, throwable);
  9. }

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

  1. @Test
  2. void testLogger() {
  3. PrintStream original = System.out;
  4. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  5. PrintStream ps = new PrintStream(baos);
  6. System.setOut(ps);
  7. LoggerFactory.setLoggerProvider(Slf4jLogger.PROVIDER);
  8. Logger log = LoggerFactory.getLogger("Foo");
  9. log.warn("123");
  10. System.out.flush();
  11. System.setOut(original);
  12. assertEquals(
  13. "WARN Foo " + this.getClass().getName() + " testLogger 51 - 123", baos.toString().trim());
  14. }

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

  1. /**
  2. * Resolves column db sql type and populates it in column descriptor if missing.
  3. */
  4. protected void resolveColumnDbSqlType(final Connection connection, final DbEntityColumnDescriptor dec) {
  5. if (dec.dbSqlType != SqlType.DB_SQLTYPE_UNKNOWN) {
  6. return;
  7. }
  8. ResultSet rs = null;
  9. DbEntityDescriptor ded = dec.getDbEntityDescriptor();
  10. try {
  11. DatabaseMetaData dmd = connection.getMetaData();
  12. rs = dmd.getColumns(null, ded.getSchemaName(), ded.getTableName(), dec.getColumnName());
  13. if (rs.next()) {
  14. dec.dbSqlType = rs.getInt("DATA_TYPE");
  15. } else {
  16. dec.dbSqlType = SqlType.DB_SQLTYPE_NOT_AVAILABLE;
  17. if (log.isWarnEnabled()) {
  18. log.warn("Column SQL type not available: " + ded.toString() + '.' + dec.getColumnName());
  19. }
  20. }
  21. } catch (SQLException sex) {
  22. dec.dbSqlType = SqlType.DB_SQLTYPE_NOT_AVAILABLE;
  23. if (log.isWarnEnabled()) {
  24. log.warn("Column SQL type not resolved: " + ded.toString() + '.' + dec.getColumnName(), sex);
  25. }
  26. } finally {
  27. DbUtil.close(rs);
  28. }
  29. }

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

  1. @Test
  2. void testLevel() {
  3. //when
  4. logger.trace(LoggerConstants.TRACE_MESSAGE);
  5. //then
  6. verify(log).trace(LoggerConstants.TRACE_MESSAGE);
  7. //when
  8. logger.debug(LoggerConstants.DEBUG_MESSAGE);
  9. //then
  10. verify(log).debug(LoggerConstants.DEBUG_MESSAGE);
  11. //when
  12. logger.info(LoggerConstants.INFO_MESSAGE);
  13. //then
  14. verify(log).info(LoggerConstants.INFO_MESSAGE);
  15. //when
  16. logger.warn(LoggerConstants.WARN_MESSAGE);
  17. //then
  18. verify(log).warn(LoggerConstants.WARN_MESSAGE);
  19. //when
  20. logger.error(LoggerConstants.ERROR_MESSAGE);
  21. //then
  22. verify(log).error(LoggerConstants.ERROR_MESSAGE);
  23. }

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

  1. @Test
  2. void testThrowable() {
  3. //given
  4. throwable = mock(Throwable.class);
  5. setUpOutputStream();
  6. //when
  7. logger.warn(LoggerConstants.WARN_MESSAGE, throwable);
  8. //then
  9. output = outputStream.toString();
  10. assertTrue(output.contains(LoggerConstants.WARN_MESSAGE));
  11. verify(throwable).printStackTrace(System.out);
  12. //setup
  13. throwable = mock(Throwable.class);
  14. //when
  15. logger.error(LoggerConstants.ERROR_MESSAGE, throwable);
  16. //then
  17. output = outputStream.toString();
  18. assertTrue(output.contains(LoggerConstants.ERROR));
  19. verify(throwable).printStackTrace(System.out);
  20. }

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

  1. @Test
  2. void testLevel() {
  3. //when
  4. logger.trace(LoggerConstants.TRACE_MESSAGE);
  5. //then
  6. verify(log).log(java.util.logging.Level.FINER, LoggerConstants.TRACE_MESSAGE);
  7. //when
  8. logger.debug(LoggerConstants.DEBUG_MESSAGE);
  9. //then
  10. verify(log).log(java.util.logging.Level.FINE, LoggerConstants.DEBUG_MESSAGE);
  11. //when
  12. logger.info(LoggerConstants.INFO_MESSAGE);
  13. //then
  14. verify(log).log(java.util.logging.Level.INFO, LoggerConstants.INFO_MESSAGE);
  15. //when
  16. logger.warn(LoggerConstants.WARN_MESSAGE);
  17. //then
  18. verify(log).log(java.util.logging.Level.WARNING, LoggerConstants.WARN_MESSAGE);
  19. //when
  20. logger.error(LoggerConstants.ERROR_MESSAGE);
  21. //then
  22. verify(log).log(java.util.logging.Level.SEVERE, LoggerConstants.ERROR_MESSAGE);
  23. }

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

  1. @Test
  2. void testLevel() {
  3. //when
  4. logger.trace(LoggerConstants.TRACE_MESSAGE);
  5. //then
  6. verify(log).trace(LoggerConstants.TRACE_MESSAGE);
  7. //when
  8. logger.debug(LoggerConstants.DEBUG_MESSAGE);
  9. //then
  10. verify(log).debug(LoggerConstants.DEBUG_MESSAGE);
  11. //when
  12. logger.info(LoggerConstants.INFO_MESSAGE);
  13. //then
  14. verify(log).info(LoggerConstants.INFO_MESSAGE);
  15. //when
  16. logger.warn(LoggerConstants.WARN_MESSAGE);
  17. //then
  18. verify(log).warn(LoggerConstants.WARN_MESSAGE);
  19. //when
  20. logger.error(LoggerConstants.ERROR_MESSAGE);
  21. //then
  22. verify(log).error(LoggerConstants.ERROR_MESSAGE);
  23. }

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

  1. @Test
  2. void testLevel() {
  3. //when
  4. logger.trace(LoggerConstants.TRACE_MESSAGE);
  5. //then
  6. verify(log).trace(LoggerConstants.TRACE_MESSAGE);
  7. //when
  8. logger.debug(LoggerConstants.DEBUG_MESSAGE);
  9. //then
  10. verify(log).debug(LoggerConstants.DEBUG_MESSAGE);
  11. //when
  12. logger.info(LoggerConstants.INFO_MESSAGE);
  13. //then
  14. verify(log).info(LoggerConstants.INFO_MESSAGE);
  15. //when
  16. logger.warn(LoggerConstants.WARN_MESSAGE);
  17. //then
  18. verify(log).warn(LoggerConstants.WARN_MESSAGE);
  19. //when
  20. logger.error(LoggerConstants.ERROR_MESSAGE);
  21. //then
  22. verify(log).error(LoggerConstants.ERROR_MESSAGE);
  23. }

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

  1. /**
  2. * Creates new DbOom.
  3. */
  4. public DbOom(
  5. final ConnectionProvider connectionProvider,
  6. final DbSessionProvider dbSessionProvider,
  7. final QueryMap queryMap) {
  8. this.connectionProvider = connectionProvider;
  9. this.dbSessionProvider = dbSessionProvider;
  10. this.queryMap = queryMap;
  11. this.dbOomConfig = new DbOomConfig();
  12. this.dbQueryConfig = new DbQueryConfig();
  13. this.dbEntityManager = new DbEntityManager(dbOomConfig);
  14. this.dbEntitySql = new DbEntitySql(this);
  15. // static init
  16. if (defaultDbOom == null) {
  17. log.info("Default DbOom is created.");
  18. defaultDbOom = this;
  19. }
  20. else {
  21. log.warn("Multiple DbOom detected.");
  22. defaultDbOom = null;
  23. }
  24. }

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

  1. @Test
  2. void testLog() {
  3. //given
  4. throwable = mock(Throwable.class);
  5. //when
  6. //The below methods are no op methods in actual implementations.
  7. //so we will not be able to verify anything
  8. logger.log(Level.DEBUG, name);
  9. logger.trace(name);
  10. logger.debug(name);
  11. logger.info(name);
  12. logger.warn(name);
  13. logger.warn(name, throwable);
  14. logger.error(name);
  15. logger.error(name, throwable);
  16. }

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

  1. logger.warn(LoggerConstants.WARN_MESSAGE);

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

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

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

  1. /**
  2. * Authenticate user and start user session.
  3. */
  4. protected JsonResult login() {
  5. T authToken;
  6. authToken = loginViaBasicAuth(servletRequest);
  7. if (authToken == null) {
  8. authToken = loginViaRequestParams(servletRequest);
  9. }
  10. if (authToken == null) {
  11. log.warn("Login failed.");
  12. return JsonResult.of(HttpStatus.error401().unauthorized("Login failed."));
  13. }
  14. log.info("login OK!");
  15. final UserSession<T> userSession = new UserSession<>(authToken, userAuth.tokenValue(authToken));
  16. userSession.start(servletRequest, servletResponse);
  17. // return token
  18. return tokenAsJson(authToken);
  19. }

相关文章