[openrtm-commit:01734] r550 - in trunk/rtmtools/jp.go.aist.rtm.rtcbuilder: lib src/jp/go/aist/rtm/rtcbuilder
openrtm @ openrtm.org
openrtm @ openrtm.org
2016年 2月 21日 (日) 02:40:30 JST
Author: ga
Date: 2016-02-21 02:40:30 +0900 (Sun, 21 Feb 2016)
New Revision: 550
Removed:
trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/lib/log4j-1.2.15.jar
trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/RTCBLogHandler.java
Log:
Modified Logger #3211
Deleted: trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/lib/log4j-1.2.15.jar
===================================================================
(Binary files differ)
Deleted: trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/RTCBLogHandler.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/RTCBLogHandler.java 2016-02-20 17:40:05 UTC (rev 549)
+++ trunk/rtmtools/jp.go.aist.rtm.rtcbuilder/src/jp/go/aist/rtm/rtcbuilder/RTCBLogHandler.java 2016-02-20 17:40:30 UTC (rev 550)
@@ -1,93 +0,0 @@
-package jp.go.aist.rtm.rtcbuilder;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-public class RTCBLogHandler {
-
- FileHandler handler;
- List<Logger> loggers;
-
- public RTCBLogHandler() throws SecurityException, IOException {
- this.loggers = new ArrayList<Logger>();
- //
- LogManager logManager = LogManager.getLogManager();
- String cname = RTCBLogHandler.class.getName();
- String propPattern = logManager.getProperty(cname + ".pattern");
- String propAppend = logManager.getProperty(cname + ".append");
- String propFormatter = logManager.getProperty(cname + ".formatter");
- String propLevel = logManager.getProperty(cname + ".level");
- if (propLevel == null) {
- propLevel = logManager.getProperty(".level");
- }
- //
- String pattern = "rtcbuilder%u.log";
- if (propPattern != null) {
- pattern = propPattern;
- }
- boolean append = false;
- if ("true".equalsIgnoreCase(propAppend)) {
- append = true;
- }
- this.handler = new FileHandler(pattern, append);
- Formatter formatter = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try {
- Class<?> clazz = loader.loadClass(propFormatter);
- formatter = (Formatter) clazz.newInstance();
- } catch (Exception e) {
- // void
- }
- if (formatter != null) {
- this.handler.setFormatter(formatter);
- } else {
- this.handler.setFormatter(new DefaultFormatter());
- }
- Level level = Level.WARNING;
- if (propLevel != null) {
- level = Level.parse(propLevel);
- }
- this.handler.setLevel(level);
- }
-
- public void start() {
- addLogger(RtcBuilderPlugin.getLogger());
- }
-
- public void stop() {
- for (Logger logger : new ArrayList<Logger>(loggers)) {
- removeLogger(logger);
- }
- loggers.clear();
- }
-
- public void addLogger(Logger logger) {
- if (logger != null) {
- logger.addHandler(handler);
- loggers.add(logger);
- }
- }
-
- public void removeLogger(Logger logger) {
- if (logger != null) {
- logger.removeHandler(handler);
- loggers.remove(logger);
- }
- }
-
- public static class DefaultFormatter extends Formatter {
- @Override
- public String format(LogRecord record) {
- return String.format("%tF %tT %s: %s%n", record.getMillis(), record
- .getMillis(), record.getLevel(), record.getMessage());
- }
- }
-
-}
More information about the openrtm-commit
mailing list