Package java.util.logging

Examples of java.util.logging.Handler


                     otherLogger.getResourceBundleName());
    }

    @Test
    public void testHandleL7dMessage() throws Exception {
        Handler handler = EasyMock.createNiceMock(Handler.class);
        LOG.addHandler(handler);
        // handler called *before* localization of message
        LogRecord record = new LogRecord(Level.WARNING, "FOOBAR_MSG");
        record.setResourceBundle(LOG.getResourceBundle());
        EasyMock.reportMatcher(new LogRecordMatcher(record));
        handler.publish(record);
        EasyMock.replay(handler);
        LOG.log(Level.WARNING, "FOOBAR_MSG");
        EasyMock.verify(handler);
        LOG.removeHandler(handler);
    }
View Full Code Here


        LOG.removeHandler(handler);
    }
   
    @Test
    public void testLogNoParamsOrThrowable() {
        Handler handler = EasyMock.createNiceMock(Handler.class);
        LOG.addHandler(handler);
        // handler called *after* localization of message
        LogRecord record = new LogRecord(Level.SEVERE, "subbed in {0} only");
        EasyMock.reportMatcher(new LogRecordMatcher(record));
        handler.publish(record);
        EasyMock.replay(handler);
        LogUtils.log(LOG, Level.SEVERE, "SUB1_MSG");
        EasyMock.verify(handler);
        LOG.removeHandler(handler);
    }
View Full Code Here

        LOG.removeHandler(handler);
    }
   
    @Test
    public void testLogNoParamsWithThrowable() {
        Handler handler = EasyMock.createNiceMock(Handler.class);
        LOG.addHandler(handler);
        // handler called *after* localization of message
        Exception ex = new Exception("x");
        LogRecord record = new LogRecord(Level.SEVERE, "subbed in {0} only");
        record.setThrown(ex);
        EasyMock.reportMatcher(new LogRecordMatcher(record));
        handler.publish(record);
        EasyMock.replay(handler);
        LogUtils.log(LOG, Level.SEVERE, "SUB1_MSG", ex);
        EasyMock.verify(handler);
        LOG.removeHandler(handler);
    }
View Full Code Here

        LOG.removeHandler(handler);
    }

    @Test
    public void testLogParamSubstitutionWithThrowable() throws Exception {
        Handler handler = EasyMock.createNiceMock(Handler.class);
        LOG.addHandler(handler);
        // handler called *after* localization of message
        Exception ex = new Exception();
        LogRecord record = new LogRecord(Level.SEVERE, "subbed in 1 only");
        record.setThrown(ex);
        EasyMock.reportMatcher(new LogRecordMatcher(record));
        handler.publish(record);
        EasyMock.replay(handler);
        LogUtils.log(LOG, Level.SEVERE, "SUB1_MSG", ex, 1);
        EasyMock.verify(handler);
        LOG.removeHandler(handler);
    }
View Full Code Here

        LOG.removeHandler(handler);
    }

    @Test
    public void testLogParamsSubstitutionWithThrowable() throws Exception {
        Handler handler = EasyMock.createNiceMock(Handler.class);
        LOG.addHandler(handler);
        // handler called *after* localization of message
        Exception ex = new Exception();
        LogRecord record = new LogRecord(Level.SEVERE, "subbed in 4 & 3");
        record.setThrown(ex);
        EasyMock.reportMatcher(new LogRecordMatcher(record));
        handler.publish(record);
        EasyMock.replay(handler);
        LogUtils.log(LOG, Level.SEVERE, "SUB2_MSG", ex, new Object[] {3, 4});
        EasyMock.verify(handler);
        LOG.removeHandler(handler);
    }
View Full Code Here

        clock,
        callbackGenerator,
        false);

    logger = Logger.getLogger(OAuthResponseParams.class.getName());
    logger.addHandler(new Handler() {
      @Override
      public void close() throws SecurityException {
      }

      @Override
View Full Code Here

    Logger fo = new MockLogger("LogManagerTestFoo2", null);
    fo.setLevel(Level.ALL);
    assertTrue(mockManager.addLogger(fo));

    Handler h = new ConsoleHandler();
    Level l = h.getLevel();
    assertNotSame(Level.OFF, h.getLevel());

    // read configuration from stream
    mockManager.readConfiguration(stream);
    stream.close();

    // level DO has effect
    assertEquals(Level.WARNING, foo.getLevel());

    // for non specified logger, level is reset to null
    assertNull(fo.getLevel());

    // read properties don't affect handler
    assertNotSame(Level.OFF, h.getLevel());
    assertSame(l, h.getLevel());
  }
View Full Code Here

         root = root.getParent();

      Handler[] handlers = root.getHandlers();
      for (int i = 0; i < handlers.length; i++)
      {
         Handler handler = handlers[i];
         if (handler instanceof ConsoleHandler)
         {
            Filter filter = new Filter()
            {
               public boolean isLoggable(LogRecord record)
               {
                  String name = record.getLoggerName();
                  for (String ns : namespaces)
                  {
                     if (name.startsWith(ns))
                        return false;
                  }
                  return true;
               }
            };
            handler.setFilter(filter);
         }
      }
   }
View Full Code Here

        /* No need to call super, this handler is not truly publishing. */
    }

    @Override
    public void publish(LogRecord record) {
        Handler h = getEnvSpecificConfiguredHandler();
        if ((h != null) && (h.isLoggable(record))) {
            h.publish(record);
        }
    }
View Full Code Here

    }

    @Override
    public void close()
        throws SecurityException {
        Handler h = getEnvSpecificConfiguredHandler();
        if (h != null) {
            h.close();
        }
    }
View Full Code Here

TOP

Related Classes of java.util.logging.Handler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.