forked from mindspore-Ecosystem/mindspore
!41542 [lite]Java和jni日志仅打屏,不存储_1.8
Merge pull request !41542 from wangtongyu6/java_jni_log
This commit is contained in:
commit
5deaee88d8
|
@ -48,12 +48,3 @@ std::string RealPath(const char *path) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_GLOG) || defined(BUILD_CORE_RUNTIME)
|
|
||||||
extern "C" {
|
|
||||||
extern void mindspore_log_init();
|
|
||||||
}
|
|
||||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|
||||||
mindspore_log_init();
|
|
||||||
return JNI_VERSION_1_4;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
package com.mindspore.config;
|
package com.mindspore.config;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.logging.FileHandler;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.logging.SimpleFormatter;
|
|
||||||
|
|
||||||
public final class MindsporeLite {
|
public final class MindsporeLite {
|
||||||
private static final Object lock = new Object();
|
private static final Object lock = new Object();
|
||||||
|
@ -14,26 +9,8 @@ public final class MindsporeLite {
|
||||||
public static Logger GetLogger() {
|
public static Logger GetLogger() {
|
||||||
if (LOGGER == null) {
|
if (LOGGER == null) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (LOGGER != null) {
|
if (LOGGER == null) {
|
||||||
return LOGGER;
|
LOGGER = Logger.getLogger(MindsporeLite.class.toString());
|
||||||
}
|
|
||||||
LOGGER = Logger.getLogger(MindsporeLite.class.toString());
|
|
||||||
String logtostderr = System.getenv("GLOG_logtostderr");
|
|
||||||
if ("0".equals(logtostderr)) {
|
|
||||||
String GLOG_log_dir = System.getenv("GLOG_log_dir");
|
|
||||||
if (GLOG_log_dir != null && !"".equals(GLOG_log_dir)) {
|
|
||||||
FileHandler fileHandler = null;
|
|
||||||
try {
|
|
||||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("uuuuMMdd-HHmmss.SSSS");
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
fileHandler = new FileHandler(GLOG_log_dir + "/MinsSporeLite.java_log." + dtf.format(now) + ".log");
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
SimpleFormatter formatter = new SimpleFormatter();
|
|
||||||
fileHandler.setFormatter(formatter);
|
|
||||||
LOGGER.addHandler(fileHandler);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue