本文整理汇总了Java中java.rmi.server.LogStream类的典型用法代码示例。如果您正苦于以下问题:Java LogStream类的具体用法?Java LogStream怎么用?Java LogStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LogStream类属于java.rmi.server包,在下文中一共展示了LogStream类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLog
import java.rmi.server.LogStream; //导入依赖的package包/类
/**
* Access log for a tri-state system property.
*
* Need to first convert override value to a log level, taking
* care to interpret a range of values between BRIEF, VERBOSE and
* SILENT.
*
* An override < 0 is interpreted to mean that the logging
* configuration should not be overridden. The level passed to the
* factories createLog method will be null in this case.
*
* Note that if oldLogName is null and old logging is on, the
* returned LogStreamLog will ignore the override parameter - the
* log will never log messages. This permits new logs that only
* write to Loggers to do nothing when old logging is active.
*
* Do not call getLog multiple times on the same logger name.
* Since this is an internal API, no checks are made to ensure
* that multiple logs do not exist for the same logger.
*/
public static Log getLog(String loggerName, String oldLogName,
int override)
{
Level level;
if (override < 0) {
level = null;
} else if (override == LogStream.SILENT) {
level = Level.OFF;
} else if ((override > LogStream.SILENT) &&
(override <= LogStream.BRIEF)) {
level = BRIEF;
} else if ((override > LogStream.BRIEF) &&
(override <= LogStream.VERBOSE))
{
level = VERBOSE;
} else {
level = Level.FINEST;
}
return logFactory.createLog(loggerName, oldLogName, level);
}
示例2: getLog
import java.rmi.server.LogStream; //导入依赖的package包/类
/**
* Access log for a tri-state system property.
*
* Need to first convert override value to a log level, taking
* care to interpret a range of values between BRIEF, VERBOSE and
* SILENT.
*
* An override {@literal <} 0 is interpreted to mean that the logging
* configuration should not be overridden. The level passed to the
* factories createLog method will be null in this case.
*
* Note that if oldLogName is null and old logging is on, the
* returned LogStreamLog will ignore the override parameter - the
* log will never log messages. This permits new logs that only
* write to Loggers to do nothing when old logging is active.
*
* Do not call getLog multiple times on the same logger name.
* Since this is an internal API, no checks are made to ensure
* that multiple logs do not exist for the same logger.
*/
public static Log getLog(String loggerName, String oldLogName,
int override)
{
Level level;
if (override < 0) {
level = null;
} else if (override == LogStream.SILENT) {
level = Level.OFF;
} else if ((override > LogStream.SILENT) &&
(override <= LogStream.BRIEF)) {
level = BRIEF;
} else if ((override > LogStream.BRIEF) &&
(override <= LogStream.VERBOSE))
{
level = VERBOSE;
} else {
level = Level.FINEST;
}
return logFactory.createLog(loggerName, oldLogName, level);
}
示例3: testGetDefaultStream001
import java.rmi.server.LogStream; //导入依赖的package包/类
public final void testGetDefaultStream001() {
byte[] ba = { 11, 25, 64, 78, 30, 15, 65, 12, 34, 79, 66, 50, 01, 00,
16 };
ByteArrayOutputStream bas = new ByteArrayOutputStream();
try {
bas.write(ba);
PrintStream ps1 = new PrintStream(bas);
ls = LogStream.log("tcp");
ls.setDefaultStream(ps1);
PrintStream ps2 = ls.getDefaultStream();
ps2.flush();
assertEquals(ps1, ps2);
} catch (Throwable e) {
fail("Failed with:" + e);
}
}
示例4: testGetDefaultStream003
import java.rmi.server.LogStream; //导入依赖的package包/类
public final void testGetDefaultStream003() {
byte[] ba = { 11, 25, 64, 78, 30, 15, 65, 12, 34, 79, 66, 50, 01, 00,
16 };
ByteArrayOutputStream bas = new ByteArrayOutputStream();
try {
PrintStream ps1 = new PrintStream(bas);
ls = LogStream.log("tcp");
PrintStream ps2 = ls.getDefaultStream();
ps2.flush();
int i = 1;
assertNotNull(ps2);
} catch (Throwable e) {
fail("Failed with:" + e);
}
}
示例5: createLog
import java.rmi.server.LogStream; //导入依赖的package包/类
public Log createLog(String loggerName, String oldLogName,
Level level)
{
LogStream stream = null;
if (oldLogName != null) {
stream = LogStream.log(oldLogName);
}
return new LogStreamLog(stream, level);
}
示例6: LogStreamLog
import java.rmi.server.LogStream; //导入依赖的package包/类
private LogStreamLog(LogStream stream, Level level) {
if ((stream != null) && (level != null)) {
/* if the stream or level is null, don't log any
* messages
*/
levelValue = level.intValue();
}
this.stream = stream;
}
示例7: LogStreamLog
import java.rmi.server.LogStream; //导入依赖的package包/类
private LogStreamLog(LogStream stream, Level level) {
if ((stream != null) && (level != null)) {
/* if the stream or level is null, dont log any
* messages
*/
levelValue = level.intValue();
}
this.stream = stream;
}
示例8: testWriteI
import java.rmi.server.LogStream; //导入依赖的package包/类
/**
* Test for java.rmi.server.LogStream.write(int b)
*/
public void testWriteI() throws Exception {
//regression test for HARMONY-1271
LogStream.log("tst").write((int)'\n');
//regression test for HARMONY-994
LogStream.log("tst").write(0);
}
示例9: testSetOutputStreamBad
import java.rmi.server.LogStream; //导入依赖的package包/类
public void testSetOutputStreamBad() throws Exception {
// Regression test HARMONY-1198
try {
LogStream ls = LogStream.log("proba");
ls.setOutputStream(null);
fail("Expected NPE");
} catch (NullPointerException e) {
// expected
}
}
示例10: testWriteArrInvalidOffLen
import java.rmi.server.LogStream; //导入依赖的package包/类
/**
* Test for java.rmi.server.LogStream.write(byte[], int, int)
* testing invalid offsets/lengths.
*/
public void testWriteArrInvalidOffLen() throws Exception {
// Regression test for HARMONY-1691
// list of invalid offsets/lengths pairs
int[][] invalidPairs = new int[][] {
{ -2, 1 },
{ 0, -6 },
{ 6, 1 },
{ 0, 6 } };
// store original default stream for LogStream
PrintStream prevOut = LogStream.getDefaultStream();
try {
// set empty default stream to not print garbage to System.out/err
LogStream.setDefaultStream(
new PrintStream(new ByteArrayOutputStream()));
LogStream ls = LogStream.log("test");
for (int i = 0; i < invalidPairs.length; ++i) {
try {
ls.write(new byte[] { 1, 1 },
invalidPairs[i][0], invalidPairs[i][1]);
fail("IndexOutOfBoundsException "
+ "is not thrown when off = " + invalidPairs[i][0]
+ ", len = " + invalidPairs[i][1]);
} catch (IndexOutOfBoundsException e) {
//expected
}
}
} finally {
// restore original stream
LogStream.setDefaultStream(prevOut);
}
}