本文整理匯總了Java中java.util.logging.LogRecord.getParameters方法的典型用法代碼示例。如果您正苦於以下問題:Java LogRecord.getParameters方法的具體用法?Java LogRecord.getParameters怎麽用?Java LogRecord.getParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.logging.LogRecord
的用法示例。
在下文中一共展示了LogRecord.getParameters方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String format(LogRecord record) {
// <pattern>%d{HH:mm:ss.SSS} [%t] %level{WARN=WARN_, DEBUG=DEBUG, ERROR=ERROR, TRACE=TRACE, INFO=INFO_} %c{36}
// - %m%n</pattern>
// %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
StringBuilder buf = new StringBuilder(256);
buf.append(dateFmt.get().format(new Date(record.getMillis())));
buf.append(" [");
buf.append(
Thread.currentThread().getId() == record.getThreadID() ? Thread.currentThread().getName() : "Unknown");
buf.append("] ");
buf.append(record.getLevel().getName());
buf.append(' ');
buf.append(abbreviateClassName(record.getLoggerName(), 36));
buf.append(" - ");
if (record.getParameters() == null) {
buf.append(record.getMessage());
} else {
buf.append(MessageFormat.format(record.getMessage(), record.getParameters()));
}
buf.append('\n');
return buf.toString();
}
示例2: isLoggable
import java.util.logging.LogRecord; //導入方法依賴的package包/類
public boolean isLoggable(LogRecord record)
{
if (record.getLoggerName() != "item") return false;
if (_excludeProcess != null)
{
//if (record.getMessage() == null) return true;
String[] messageList = record.getMessage().split(":");
if (messageList.length < 2 || !_excludeProcess.contains(messageList[1])) return true;
}
if (_excludeItemType != null)
{
//if (record.getParameters() == null || record.getParameters().length == 0 || !(record.getParameters()[0] instanceof L2ItemInstance)) return true;
L2ItemInstance item = ((L2ItemInstance)record.getParameters()[0]);
if (!_excludeItemType.contains(item.getItemType().toString())) return true;
}
return (_excludeProcess == null && _excludeItemType == null);
}
示例3: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
Runnable r = null;
synchronized (this) {
String message = record.getMessage();
if (message != null) {
final Object[] params = record.getParameters();
if (params != null && params.length > 0) {
message = MessageFormat.format(message, params);
}
if (message.equals(expected.peek())) {
if (VERBOSE) {
System.out.println(message);
}
expected.remove();
}
r = actions.get(message);
}
}
if (r != null) {
r.run();
}
}
示例4: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public synchronized void publish(LogRecord record) {
final String message = record.getMessage();
if (JFXApplicationClassChooser.LOG_INIT.equals(message)) {
callInterceptor(0);
} else if (JFXApplicationClassChooser.LOG_MAIN_CLASSES.equals(message)) {
callInterceptor(1);
final String[] result = ((Set<String>)record.getParameters()[0]).toArray(new String[0]);
final boolean scan = (Boolean) record.getParameters()[1];
final String[] expected = mainClasses.removeFirst();
Arrays.sort(result);
Arrays.sort(expected);
final boolean last = mainClasses.isEmpty();
if (last == scan) {
failure = "Expected " + (!last) + ", Result: " + scan; //NOI18N
notifyAll();
} else if (!Arrays.equals(expected, result)) {
failure = "Expected " + Arrays.toString(expected) + ", Result: " + Arrays.toString(result); //NOI18N
notifyAll();
} else if (last) {
notifyAll();
}
}
}
示例5: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
// Log if parent cannot log the message ONLY.
if (!log.getParent().isLoggable(record.getLevel())) {
String message;
Object[] params = record.getParameters();
if (params == null || params.length == 0) {
message = record.getMessage();
} else {
message = MessageFormat.format(record.getMessage(), record.getParameters());
}
System.err.printf("%s: %s\n", record.getLevel(), message); // NOI18N
if (record.getThrown() != null) {
record.getThrown().printStackTrace(System.err);
}
}
}
示例6: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage());
if (params != null)
{
for (Object p : params)
{
if (p == null)
{
continue;
}
StringUtil.append(output, ", ", p.toString());
}
}
output.append(Config.EOL);
return output.toString();
}
示例7: getLocalizedMessage
import java.util.logging.LogRecord; //導入方法依賴的package包/類
/** Extracts localized message from a LogRecord */
private static final String getLocalizedMessage(LogRecord rec) {
ResourceBundle rb = rec.getResourceBundle();
if (rb == null) {
return null;
}
String msg = rec.getMessage();
if (msg == null) {
return null;
}
String format = rb.getString(msg);
Object[] arr = rec.getParameters();
if (arr == null) {
return format;
}
return MessageFormat.format(format, arr);
}
示例8: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String format(LogRecord record)
{
StringBuilder output = new StringBuilder();
output.append('[');
output.append(dateFmt.format(new Date(record.getMillis())));
output.append(']');
output.append(' ');
output.append(record.getMessage());
for (Object p : record.getParameters())
{
if (p == null) continue;
output.append(',');
output.append(' ');
if (p instanceof L2ItemInstance)
{
L2ItemInstance item = (L2ItemInstance)p;
output.append("item " + item.getObjectId() + ":");
if (item.getEnchantLevel() > 0) output.append("+" + item.getEnchantLevel() + " ");
output.append(item.getItem().getName());
output.append("(" + item.getCount() + ")");
}
//else if (p instanceof L2PcInstance)
// output.append(((L2PcInstance)p).getName());
else output.append(p.toString()/* + ":" + ((L2Object)p).getObjectId()*/);
}
output.append(CRLF);
return output.toString();
}
示例9: MapEvent
import java.util.logging.LogRecord; //導入方法依賴的package包/類
MapEvent(TLEntity entity, LogRecord record) throws DataFormatException {
this.record = record;
this.entity = entity;
for (Object parameter : record.getParameters()) {
if (parameter instanceof LogMapMark) {
this.mapMark = (LogMapMark) parameter;
return;
}
}
throw new DataFormatException("LogRecord " + record.toString() + " doesn't have a log map event as parameter.");
}
示例10: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish (LogRecord record) {
if (record.getMessage().contains("execEnv():")) {
for (Object o : record.getParameters()) {
if (o.toString().contains("hg") && o.toString().contains("log") && o.toString().contains(revision)) {
++called;
break;
}
}
} else if (record.getMessage().contains("persisting changePaths to disk cache")) {
persisted = true;
} else if (record.getMessage().contains("loading changePaths from disk cache")) {
loadedFromCache = true;
}
}
示例11: getParam
import java.util.logging.LogRecord; //導入方法依賴的package包/類
private static <T> T getParam(LogRecord r, int index, Class<T> type) {
if (r == null || r.getParameters() == null || r.getParameters().length <= index) {
return null;
}
Object o = r.getParameters()[index];
return type.isInstance(o) ? type.cast(o) : null;
}
示例12: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
if ("Request to add indexing job for root: {0}".equals(record.getMessage()) &&
record.getParameters().length == 1 &&
currentRoot.toURL().equals(record.getParameters()[0])) { //NOI18N
synchronized (this) {
numberOfEvents++;
notifyAll();
}
}
}
示例13: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
final String message = record.getMessage();
final Object param = record.getParameters()[0];
for (Iterator<Pair<Pair<String, Object>, CountDownLatch>> it = condition.iterator(); it.hasNext();) {
final Pair<Pair<String,Object>,CountDownLatch> cnd = it.next();
if (cnd != null && cnd.first().first().equals(message) && cnd.first().second().equals(param)) {
//System.out.println("GOT: " + cnd.first.first + " " + cnd.first.second);
it.remove();
cnd.second().countDown();
break;
}
}
}
示例14: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
String message = record.getMessage();
if ("USG_VCS_CMD".equals(message)) {
++numberOfEvents;
event = new CommandUsageEvent();
event.vcs = (String) record.getParameters()[0];
event.time = (Long) record.getParameters()[1];
event.modifications = (Long) record.getParameters()[2];
event.command = (String) record.getParameters()[3];
event.external = "EXTERNAL".equals(record.getParameters()[4]);
}
}
示例15: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params.length * 50), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage());
for (Object p : record.getParameters())
{
if (p == null)
{
continue;
}
output.append(", ");
if (p instanceof L2ItemInstance)
{
final L2ItemInstance item = (L2ItemInstance) p;
StringUtil.append(output, "item ", String.valueOf(item.getObjectId()), ":");
if (item.getEnchantLevel() > 0)
{
StringUtil.append(output, "+", String.valueOf(item.getEnchantLevel()), " ");
}
StringUtil.append(output, item.getItem().getName(), "(", String.valueOf(item.getCount()), ")");
}
// else if (p instanceof L2PcInstance)
// output.append(((L2PcInstance)p).getName());
else
{
output.append(p.toString()/* + ":" + ((L2Object)p).getObjectId() */);
}
}
output.append(Config.EOL);
return output.toString();
}