Search in sources :

Example 51 with SimpleFormatter

use of java.util.logging.SimpleFormatter in project j2objc by google.

the class HandlerTest method testGetSetFormatter_Normal.

/*
	 * Test setFilter with insufficient privilege.
	 *
	public void testSetFilter_InsufficientPrivilege() throws Exception {
		MockHandler h = new MockHandler();
		SecurityManager oldMan = System.getSecurityManager();
		System.setSecurityManager(new MockSecurityManager());

		// set null
		try {

			h.setFilter(null);
			fail("Should throw SecurityException!");
		} catch (SecurityException e) {
		} finally {
			System.setSecurityManager(oldMan);
		}
		// set a normal value
		System.setSecurityManager(new MockSecurityManager());
		try {

			h.setFilter(new MockFilter());
			fail("Should throw SecurityException!");
		} catch (SecurityException e) {
		} finally {
			System.setSecurityManager(oldMan);
		}
	}
	*/
/*
	 * Test getFormatter & setFormatter methods with non-null value.
	 */
public void testGetSetFormatter_Normal() throws Exception {
    MockHandler h = new MockHandler();
    Formatter f = new SimpleFormatter();
    h.setFormatter(f);
    assertSame(f, h.getFormatter());
}
Also used : SimpleFormatter(java.util.logging.SimpleFormatter) Formatter(java.util.logging.Formatter) SimpleFormatter(java.util.logging.SimpleFormatter)

Example 52 with SimpleFormatter

use of java.util.logging.SimpleFormatter in project j2objc by google.

the class HandlerTest method testGetSetFormatter_Null.

/*
	 * Test getFormatter & setFormatter methods with null.
	 */
public void testGetSetFormatter_Null() throws Exception {
    MockHandler h = new MockHandler();
    // test set null
    try {
        h.setFormatter(null);
        fail("Should throw NullPointerException!");
    } catch (NullPointerException e) {
    }
    // test reset null
    try {
        h.setFormatter(new SimpleFormatter());
        h.setFormatter(null);
        fail("Should throw NullPointerException!");
    } catch (NullPointerException e) {
    }
}
Also used : SimpleFormatter(java.util.logging.SimpleFormatter)

Example 53 with SimpleFormatter

use of java.util.logging.SimpleFormatter in project j2objc by google.

the class ConsoleHandlerTest method testConstructor_NoProperties.

/*
	 * Test the constructor with no relevant log manager properties are set.
	 */
public void testConstructor_NoProperties() {
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.level"));
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.filter"));
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.formatter"));
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.encoding"));
    ConsoleHandler h = new ConsoleHandler();
    assertSame(h.getLevel(), Level.INFO);
    assertTrue(h.getFormatter() instanceof SimpleFormatter);
    assertNull(h.getFilter());
    assertSame(h.getEncoding(), null);
}
Also used : SimpleFormatter(java.util.logging.SimpleFormatter) ConsoleHandler(java.util.logging.ConsoleHandler)

Example 54 with SimpleFormatter

use of java.util.logging.SimpleFormatter in project j2objc by google.

the class StreamHandlerTest method testConstructor_NoParameter_NoProperties.

/*
	 * Test the constructor with no parameter, and no relevant log manager
	 * properties are set.
	 */
public void testConstructor_NoParameter_NoProperties() {
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.level"));
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.filter"));
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.formatter"));
    assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.encoding"));
    StreamHandler h = new StreamHandler();
    assertSame(Level.INFO, h.getLevel());
    assertTrue(h.getFormatter() instanceof SimpleFormatter);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
}
Also used : StreamHandler(java.util.logging.StreamHandler) SimpleFormatter(java.util.logging.SimpleFormatter)

Example 55 with SimpleFormatter

use of java.util.logging.SimpleFormatter in project malmo by Microsoft.

the class TCPSocketHelper method setLogging.

static void setLogging(boolean log) {
    logging = log;
    if (log == true && filehandler == null) {
        try {
            filehandler = new FileHandler("TCPLog.txt");
            filehandler.setFormatter(new SimpleFormatter());
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        logger.addHandler(filehandler);
    }
}
Also used : SimpleFormatter(java.util.logging.SimpleFormatter) IOException(java.io.IOException) FileHandler(java.util.logging.FileHandler)

Aggregations

SimpleFormatter (java.util.logging.SimpleFormatter)100 FileHandler (java.util.logging.FileHandler)59 Logger (java.util.logging.Logger)36 File (java.io.File)28 Handler (java.util.logging.Handler)23 IOException (java.io.IOException)17 StreamHandler (java.util.logging.StreamHandler)16 Properties (java.util.Properties)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)14 LogRecord (java.util.logging.LogRecord)13 BalancerRunner (org.mobicents.tools.sip.balancer.BalancerRunner)13 Config (edu.neu.ccs.pyramid.configuration.Config)11 ConsoleHandler (java.util.logging.ConsoleHandler)10 Formatter (java.util.logging.Formatter)9 Test (org.junit.Test)7 MockResponse (com.google.mockwebserver.MockResponse)6 HttpClient (org.apache.http.client.HttpClient)6 HttpGet (org.apache.http.client.methods.HttpGet)6 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)6 Pair (edu.neu.ccs.pyramid.util.Pair)3