MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / log

Method log

src/org/opensourcephysics/controls/OSPLog.java:1118–1160  ·  view source on GitHub ↗
(Level level, String msg)

Source from the content-addressed store, hash-verified

1116 }
1117
1118 private static void log(Level level, String msg) {
1119 if (OSPRuntime.dontLog)
1120 return;
1121 LogRecord record = new LogRecord(level, msg);
1122
1123 String className = null, methodName = null;
1124 if (OSPRuntime.isJS) {
1125
1126 OSPRuntime.showStatus("OSPLog[" + level + "] " + msg);
1127
1128 try {
1129 /**
1130 * @j2sNative var o = arguments.callee.caller.caller; methodName = o &&
1131 * o.exName; className = o && o.exClazz && o.exClazz.__CLASS_NAME__;
1132 */
1133 } catch (Throwable t) {
1134 // ignore -- something went wrong
1135 }
1136 } else {
1137 StackTraceElement stack[] = (new Throwable()).getStackTrace();
1138 // find the first method not in class OSPLog
1139 for(int i = 0; i<stack.length; i++) {
1140 StackTraceElement el = stack[i];
1141 className = el.getClassName();
1142 if(!className.equals("org.opensourcephysics.controls.OSPLog")) { //$NON-NLS-1$
1143 // set the source class and method
1144 methodName = el.getMethodName();
1145 break;
1146 }
1147 }
1148 }
1149 if (methodName != null) {
1150 record.setSourceClassName(className);
1151 record.setSourceMethodName(methodName);
1152 }
1153
1154 if(OSPLOG!=null) {
1155 OSPLOG.getLogger().log(record);
1156 } else {
1157 messageStorage[messageIndex++] = record;
1158 messageIndex = messageIndex%messageStorage.length;
1159 }
1160 }
1161
1162/**
1163 * A class that formats a record as if this were the console.

Callers 12

severeMethod · 0.95
warningMethod · 0.95
infoMethod · 0.95
configMethod · 0.95
fineMethod · 0.95
finerMethod · 0.95
finestMethod · 0.95
showLogMethod · 0.45
saveXMLMethod · 0.45
setLogToFileActionMethod · 0.45
getFileHandlerMethod · 0.45
logMsgMethod · 0.45

Calls 4

showStatusMethod · 0.95
getClassNameMethod · 0.80
getLoggerMethod · 0.80
equalsMethod · 0.65

Tested by

no test coverage detected