use of java.util.logging.FileHandler in project robovm by robovm.
the class OldFileHandlerTest method testFileHandler_4params.
public void testFileHandler_4params() throws Exception {
int limit = 120;
int count = 1;
boolean append = false;
do {
append = !append;
handler = new FileHandler("%t/log/string", limit, count, append);
assertEquals("character encoding is non equal to actual value", "iso-8859-1", handler.getEncoding());
assertNotNull("Filter is null", handler.getFilter());
assertNotNull("Formatter is null", handler.getFormatter());
assertEquals("is non equal to actual value", Level.FINE, handler.getLevel());
assertNotNull("ErrorManager is null", handler.getErrorManager());
handler.publish(r);
handler.close();
// append mode is true
for (int i = 0; i < 3; i++) {
handler = new FileHandler("%t/log/string", limit, count, append);
handler.publish(r);
handler.close();
}
if (append) {
assertFileContent(TEMPPATH + SEP + "log", "/string", new LogRecord[] { r, null, r, null, r, null, r }, new MockFormatter());
} else {
assertFileContent(TEMPPATH + SEP + "log", "/string", new LogRecord[] { r }, new MockFormatter());
}
} while (append);
try {
new FileHandler("", limit, count, true);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new FileHandler("%t/log/string", -1, count, false);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new FileHandler("%t/log/string", limit, 0, true);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
}
use of java.util.logging.FileHandler in project robovm by robovm.
the class OldFileHandlerTest method testFileHandler_3params.
public void testFileHandler_3params() throws Exception {
int limit = 120;
int count = 1;
handler = new FileHandler("%t/log/string", limit, count);
assertEquals("character encoding is non equal to actual value", "iso-8859-1", handler.getEncoding());
assertNotNull("Filter is null", handler.getFilter());
assertNotNull("Formatter is null", handler.getFormatter());
assertEquals("is non equal to actual value", Level.FINE, handler.getLevel());
assertNotNull("ErrorManager is null", handler.getErrorManager());
handler.publish(r);
handler.close();
// append mode is true
for (int i = 0; i < 3; i++) {
handler = new FileHandler("%t/log/string", limit, count);
handler.publish(r);
handler.close();
}
assertFileContent(TEMPPATH + SEP + "log", "/string", new LogRecord[] { r, null, r, null, r, null, r }, new MockFormatter());
try {
new FileHandler("", limit, count);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new FileHandler("%t/log/string", -1, count);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new FileHandler("%t/log/string", limit, 0);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
}
use of java.util.logging.FileHandler in project robovm by robovm.
the class OldFileHandlerTest method testClose.
public void testClose() throws Exception {
FileHandler h = new FileHandler("%t/log/stringPublish");
h.publish(r);
h.close();
assertFileContent(TEMPPATH + SEP + "log", "stringPublish", h.getFormatter());
}
use of java.util.logging.FileHandler in project robovm by robovm.
the class OldFileHandlerTest method testFileHandler.
public void testFileHandler() throws Exception {
assertEquals("character encoding is non equal to actual value", "iso-8859-1", handler.getEncoding());
assertNotNull("Filter is null", handler.getFilter());
assertNotNull("Formatter is null", handler.getFormatter());
assertEquals("is non equal to actual value", Level.FINE, handler.getLevel());
assertNotNull("ErrorManager is null", handler.getErrorManager());
handler.publish(r);
handler.close();
// append mode is true
for (int i = 0; i < 3; i++) {
handler = new FileHandler();
handler.publish(r);
handler.close();
}
assertFileContent(TEMPPATH + SEP + "log", "java0.test.0", new LogRecord[] { r, null, r, null, r, null, r }, new MockFormatter());
}
use of java.util.logging.FileHandler in project Towny by ElgarL.
the class TownyLogger method setupLogger.
public static void setupLogger(Logger logger, String logFolder, String filename, Formatter formatter, boolean append) {
try {
FileHandler fh = new FileHandler(logFolder + FileMgmt.fileSeparator() + filename, append);
fh.setFormatter(formatter);
logger.addHandler(fh);
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations