Java Code Examples for java.util.logging.Level#WARNING
The following examples show how to use
java.util.logging.Level#WARNING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FernflowerJDKLogger.java From windup with Eclipse Public License 1.0 | 6 votes |
private Level getLevel(Severity severity) { switch (severity) { case TRACE: return Level.FINE; case INFO: return Level.INFO; case WARN: return Level.WARNING; case ERROR: return Level.SEVERE; default: return Level.INFO; } }
Example 2
Source File: LoggingExceptionTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testLoggedExceptionIsPrinted() throws Exception { Exception ex = new IOException("Ahoj"); LogRecord rec = new LogRecord(Level.WARNING, "Cannot process {0}"); rec.setThrown(ex); rec.setParameters(new Object[] { "Jardo" }); Logger.getLogger("global").log(rec); File[] arr = getWorkDir().listFiles(); assertEquals("One log file", 1, arr.length); String s = LoggingTest.readFile(arr[0]); if (s.indexOf("Ahoj") == -1) { fail("There needs to be 'Ahoj':\n" + s); } if (s.indexOf("Jardo") == -1) { fail("There needs to be 'Jardo':\n" + s); } if (s.indexOf("testLoggedExceptionIsPrinted") == -1) { fail("There needs to be name of the method:\n" + s); } }
Example 3
Source File: JulLogTest.java From mongodb-async-driver with Apache License 2.0 | 6 votes |
/** * Test for the {@link AbstractLog#warn(String)} method. */ @Test public void testWarnString() { final String method = "testWarnString"; final String messsage = "Warning Message"; final Level level = Level.WARNING; myTestLog.warn(messsage); final List<LogRecord> records = myCaptureHandler.getRecords(); assertThat(records.size(), is(1)); final LogRecord record = records.get(0); assertThat(record.getLevel(), is(level)); assertThat(record.getLoggerName(), is(JulLogTest.class.getName())); assertThat(record.getMessage(), is(messsage)); assertThat(record.getSourceClassName(), is(JulLogTest.class.getName())); assertThat(record.getSourceMethodName(), is(method)); assertThat(record.getThreadID(), is((int) Thread.currentThread() .getId())); assertThat(record.getThrown(), nullValue()); }
Example 4
Source File: WindowManagerImpl.java From netbeans with Apache License 2.0 | 5 votes |
/** Weaker form of assertion to control if client's code is calling * winsys from ED thread. Level of logged exception is lower if * assertions are disabled (for releases etc). */ static void warnIfNotInEDT () { Level level = assertsEnabled ? Level.WARNING : Level.FINE; if(!SwingUtilities.isEventDispatchThread()) { // tries to catch known JDK problem, SwingUtilities.isEventDispatchThread() // returns false even if it *is* in ED thread. // if we find "java.awt.EventDispatchThread" stack line, it's probable // that we hit this JDK problem (see links below) boolean isJDKProblem = false; StackTraceElement[] elems = Thread.currentThread().getStackTrace(); for (StackTraceElement elem : elems) { if ("java.awt.EventDispatchThread".equals(elem.getClassName())) { isJDKProblem = true; break; } } if (!isJDKProblem) { // problem somewhere in NetBeans modules' code Logger.getLogger(WindowManagerImpl.class.getName()).log(level, null, new java.lang.IllegalStateException( "Problem in some module which uses Window System: " + ASSERTION_ERROR_MESSAGE)); } else { // probably known problem in JDK Logger.getLogger(WindowManagerImpl.class.getName()).log(level, null, new java.lang.IllegalStateException( "Known problem in JDK occurred. If you are interested, vote and report at:\n" + "http://bugs.sun.com/view_bug.do?bug_id=6424157, http://bugs.sun.com/view_bug.do?bug_id=6553239 \n" + "Also see related discussion at http://www.netbeans.org/issues/show_bug.cgi?id=90590")); } } }
Example 5
Source File: JavaUtilLoggerImpl.java From birt with Eclipse Public License 1.0 | 5 votes |
public void log( Exception ex ) { if ( logger.isLoggable( Level.WARNING ) ) { LogRecord lr = new LogRecord( Level.WARNING, "Exception" ); //$NON-NLS-1$ lr.setThrown( ex ); String[] rt = inferCaller( ); lr.setSourceClassName( rt[0] ); lr.setSourceMethodName( rt[1] ); logger.log( lr ); } }
Example 6
Source File: RoboconfLogFormatter.java From roboconf-platform with Apache License 2.0 | 5 votes |
/** * @return the maximum length of a log level */ static int findMaxLevelLength() { Level[] levels = new Level[] { Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING }; int result = -1; for( Level level : levels ) result = Math.max( result, level.toString().length()); return result; }
Example 7
Source File: LogRecordMatcherTest.java From beam with Apache License 2.0 | 5 votes |
@Test public void testLevelMismatch() { LogRecord record = new LogRecord(Level.WARNING, "abc"); try { assertThat(record, LogRecordMatcher.hasLog(Level.CONFIG, "")); } catch (AssertionError e) { return; } fail("Expected exception not thrown"); }
Example 8
Source File: Log4j2Logger.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
private Level fromL4J(final org.apache.logging.log4j.Level l) { Level l2 = null; switch (l.getStandardLevel()) { case ALL: l2 = Level.ALL; break; case FATAL: l2 = Level.SEVERE; break; case ERROR: l2 = Level.SEVERE; break; case WARN: l2 = Level.WARNING; break; case INFO: l2 = Level.INFO; break; case DEBUG: l2 = Level.FINE; break; case OFF: l2 = Level.OFF; break; case TRACE: l2 = Level.FINEST; break; default: l2 = Level.FINE; } return l2; }
Example 9
Source File: CalcAddins.java From sis with Apache License 2.0 | 5 votes |
/** * Reports an exception. This is used if an exception occurred in a method that can not return * a {@link String} instance. This method logs the stack trace at {@link Level#WARNING}. * * @param method the method from which an exception occurred. * @param exception the exception. */ final void reportException(final String method, final Exception exception) { final Logger logger = getLogger(); final LogRecord record = new LogRecord(Level.WARNING, getLocalizedMessage(exception)); record.setLoggerName(logger.getName()); record.setSourceClassName(getClass().getName()); record.setSourceMethodName(method); record.setThrown(exception); logger.log(record); }
Example 10
Source File: JavaLoggingIT.java From glowroot with Apache License 2.0 | 5 votes |
@Override public void transactionMarker() { logger.log(new LogRecord(Level.FINEST, "vwx__")); logger.log(new LogRecord(Level.FINER, "wxy__")); logger.log(new LogRecord(Level.FINE, "xyz__")); logger.log(new LogRecord(Level.CONFIG, "bcd__")); logger.log(new LogRecord(Level.INFO, "cde__")); LogRecord lr = new LogRecord(Level.WARNING, "def__"); lr.setLoggerName(logger.getName()); // test logger name logger.log(lr); logger.log(new LogRecord(Level.SEVERE, "efg__")); }
Example 11
Source File: L4MLogger.java From symja_android_library with GNU General Public License v3.0 | 5 votes |
/** * Make a formated info log * * @param fmt * format specification * @param args * objects to log */ public void info(final String fmt, final Object... args) { String msg = null; if (null != fmt) { try { msg = String.format(fmt, args); super.log(Level.INFO, msg); } catch (IllegalFormatConversionException e) { msg = "wrong formated logging: " + e.getMessage(); super.log(Level.WARNING, msg); } } else { error("no format string specified for: " + Arrays.toString(args)); } }
Example 12
Source File: ProjectOpTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testProjectOpError() throws Exception { LogRecord rec = new LogRecord(Level.WARNING, "UI_CLOSED_PROJECTS"); rec.setParameters(new Object[] { "kuk", "buch", "org.netbeans.modules.xml.schema.model/1" }); ProjectOp op = ProjectOp.valueOf(rec); assertNull("Not recognized log", op); }
Example 13
Source File: JdkMessageLogger.java From knox with Apache License 2.0 | 5 votes |
private static Level toLevel( final MessageLevel level ) { switch( level ) { case FATAL: return Level.SEVERE; case ERROR: return Level.SEVERE; case WARN: return Level.WARNING; case INFO: return Level.INFO; case DEBUG: return Level.FINE; case TRACE: return Level.FINEST; default: return Level.OFF; } }
Example 14
Source File: FastLogFormatter.java From moleculer-java with MIT License | 4 votes |
public String format(LogRecord record) { line.setLength(0); line.append('['); line.append(Instant.ofEpochMilli(record.getMillis()).toString()); final Level l = record.getLevel(); line.append("] "); if (l == Level.SEVERE) { line.append(SEVERE); } else if (l == Level.WARNING) { line.append(WARNING); } else if (l == Level.INFO) { line.append(INFO); } else if (l == Level.CONFIG) { line.append(CONFIG); } else if (l == Level.FINE) { line.append(FINE); } else if (l == Level.FINER) { line.append(FINER); } else { line.append(FINEST); } String className = record.getSourceClassName(); int n; if (className == null) { className = "unknown"; } else { n = className.lastIndexOf('$'); if (n > -1) { className = className.substring(0, n); } } line.append(className); n = line.length(); if (n > position || position - n > 30) { position = n; } n = 1 + position - n; if (n > 0) { for (int i = 0; i < n; i++) { line.append(' '); } } line.append(formatMessage(record)); line.append(BREAK); // Dump error final Throwable cause = record.getThrown(); if (cause != null) { StringBuilder errors = new StringBuilder(256); n = appendMessages(errors, cause); String trace = errors.toString().trim(); if (!trace.isEmpty()) { for (int i = 0; i < n; i++) { line.append('-'); } line.append(BREAK); line.append(trace); line.append(BREAK); for (int i = 0; i < n; i++) { line.append('-'); } line.append(BREAK); } line.append("Trace: "); line.append(cause.toString()); line.append(BREAK); StackTraceElement[] array = cause.getStackTrace(); if (array != null && array.length > 0) { for (n = 0; n < array.length; n++) { line.append("-> ["); line.append(n); line.append("] "); line.append(array[n]); line.append(BREAK); } } } return line.toString(); }
Example 15
Source File: ChatHandlerTest.java From triplea with GNU General Public License v3.0 | 4 votes |
private LogRecord newLoggableLogRecordWithMultipleLines() { return new LogRecord(Level.WARNING, "message\nmessage2\n"); }
Example 16
Source File: AbstractDelegatingLogger.java From cxf with Apache License 2.0 | 4 votes |
public void warning(String msg) { if (isLoggable(Level.WARNING)) { LogRecord lr = new LogRecord(Level.WARNING, msg); doLog(lr); } }
Example 17
Source File: AntArtifactTest.java From netbeans with Apache License 2.0 | 4 votes |
protected @Override Level logLevel() { return Level.WARNING; }
Example 18
Source File: DataMoveTest.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Level logLevel() { return Level.WARNING; }
Example 19
Source File: StaxDataStore.java From sis with Apache License 2.0 | 3 votes |
/** * Forwards StAX warnings to {@link DataStore} listeners. * This method is invoked by {@link XMLStreamReader} when needed. * * @param message the message to put in a logging record. * @param errorType ignored. * @param info ignored. * @param location ignored. */ @Override public void report(String message, String errorType, Object info, Location location) { final LogRecord record = new LogRecord(Level.WARNING, message); record.setSourceClassName(StaxDataStore.this.getClass().getCanonicalName()); // record.setLoggerName(…) will be invoked by 'listeners' with inferred name. listeners.warning(record); }
Example 20
Source File: L4MLogger.java From symja_android_library with GNU General Public License v3.0 | 2 votes |
/** * Make a warning log. * * @param msg * message to log */ @Override public void warning(final String msg) { super.log(Level.WARNING, msg); }