[openrtm-commit:01730] r546 - in trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles: . META-INF lib src/jp/go/aist/rtm/toolscommon/profiles/util

openrtm @ openrtm.org openrtm @ openrtm.org
2016年 2月 21日 (日) 02:38:34 JST


Author: ga
Date: 2016-02-21 02:38:34 +0900 (Sun, 21 Feb 2016)
New Revision: 546

Added:
   trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/logback-classic-1.1.3.jar
   trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/logback-core-1.1.3.jar
   trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/slf4j-api-1.7.13.jar
   trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/LoggerUtil.java
Modified:
   trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/META-INF/MANIFEST.MF
   trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/build.properties
   trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/XmlHandler.java
Log:
Modified Logger #3211

Modified: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/META-INF/MANIFEST.MF
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/META-INF/MANIFEST.MF	2016-02-20 17:38:11 UTC (rev 545)
+++ trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/META-INF/MANIFEST.MF	2016-02-20 17:38:34 UTC (rev 546)
@@ -6,34 +6,64 @@
 Bundle-SymbolicName: jp.go.aist.rtm.toolscommon.profiles;singleton:=tr
  ue
 Bundle-Version: 1.1.0.rc4v20130124
-Bundle-ClassPath: .,schema/,lib/jyaml-1.3.jar,lib/jaxb-impl.jar
+Bundle-ClassPath: .,
+ schema/,
+ lib/jyaml-1.3.jar,
+ lib/jaxb-impl.jar,
+ lib/slf4j-api-1.7.13.jar,
+ lib/logback-classic-1.1.3.jar,
+ lib/logback-core-1.1.3.jar
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-Export-Package: com.sun.xml.bind; uses:="javax.xml.bind.annotation.ada
- pters,  javax.xml.namespace,  org.xml.sax,  com.sun.xml.bind.v2.runti
- me.reflect,  javax.xml.bind",com.sun.xml.bind.annotation,com.sun.xml.
- bind.api; uses:="org.w3c.dom,  javax.xml.namespace,  org.xml.sax,  co
- m.sun.xml.bind.v2.runtime,  javax.xml.bind.attachment,  javax.xml.str
- eam,  javax.xml.transform,  com.sun.xml.bind.v2.model.annotation,  ja
- vax.xml.bind",com.sun.xml.bind.api.impl,com.sun.xml.bind.marshaller;u
- ses:="org.xml.sax.helpers,org.w3c.dom,org.xml.sax",com.sun.xml.bind.u
- nmarshaller; uses:="javax.xml.bind,  com.sun.xml.bind.v2.runtime.unma
- rshaller,  org.w3c.dom,  org.xml.sax",com.sun.xml.bind.util;uses:="ja
- vax.xml.bind.helpers,com.sun.xml.bind,org.xml.sax",com.sun.xml.bind.v
- 2,com.sun.xml.bind.v2.bytecode,com.sun.xml.bind.v2.model.annotation,c
- om.sun.xml.bind.v2.model.core,com.sun.xml.bind.v2.model.impl,com.sun.
- xml.bind.v2.model.nav,com.sun.xml.bind.v2.model.runtime,com.sun.xml.b
- ind.v2.runtime,com.sun.xml.bind.v2.runtime.output,com.sun.xml.bind.v2
- .runtime.property,com.sun.xml.bind.v2.runtime.reflect,com.sun.xml.bin
- d.v2.runtime.reflect.opt,com.sun.xml.bind.v2.runtime.unmarshaller,com
- .sun.xml.bind.v2.schemagen,com.sun.xml.bind.v2.schemagen.episode,com.
- sun.xml.bind.v2.schemagen.xmlschema,com.sun.xml.bind.v2.util,jp.go.ai
- st.rtm.toolscommon.profiles.util;uses:="junit.framework",org.openrtp.
- namespaces.deploy,org.openrtp.namespaces.rtc.version01;uses:="javax.x
- ml.bind,javax.xml.datatype",org.openrtp.namespaces.rtc.version02;uses
- :="javax.xml.bind,javax.xml.datatype",org.openrtp.namespaces.rts.vers
- ion01;uses:="javax.xml.bind,javax.xml.datatype",org.openrtp.namespace
- s.rts.version02;uses:="javax.xml.bind,javax.xml.datatype"
+Export-Package: com.sun.xml.bind;
+  uses:="javax.xml.bind.annotation.adapters,
+   javax.xml.namespace,
+   org.xml.sax,
+   com.sun.xml.bind.v2.runtime.reflect,
+   javax.xml.bind",
+ com.sun.xml.bind.annotation,
+ com.sun.xml.bind.api;
+  uses:="org.w3c.dom,
+   javax.xml.namespace,
+   org.xml.sax,
+   com.sun.xml.bind.v2.runtime,
+   javax.xml.bind.attachment,
+   javax.xml.stream,
+   javax.xml.transform,
+   com.sun.xml.bind.v2.model.annotation,
+   javax.xml.bind",
+ com.sun.xml.bind.api.impl,
+ com.sun.xml.bind.marshaller;uses:="org.xml.sax.helpers,org.w3c.dom,org.xml.sax",
+ com.sun.xml.bind.unmarshaller;
+  uses:="javax.xml.bind,
+   com.sun.xml.bind.v2.runtime.unmarshaller,
+   org.w3c.dom,
+   org.xml.sax",
+ com.sun.xml.bind.util;uses:="javax.xml.bind.helpers,com.sun.xml.bind,org.xml.sax",
+ com.sun.xml.bind.v2,
+ com.sun.xml.bind.v2.bytecode,
+ com.sun.xml.bind.v2.model.annotation,
+ com.sun.xml.bind.v2.model.core,
+ com.sun.xml.bind.v2.model.impl,
+ com.sun.xml.bind.v2.model.nav,
+ com.sun.xml.bind.v2.model.runtime,
+ com.sun.xml.bind.v2.runtime,
+ com.sun.xml.bind.v2.runtime.output,
+ com.sun.xml.bind.v2.runtime.property,
+ com.sun.xml.bind.v2.runtime.reflect,
+ com.sun.xml.bind.v2.runtime.reflect.opt,
+ com.sun.xml.bind.v2.runtime.unmarshaller,
+ com.sun.xml.bind.v2.schemagen,
+ com.sun.xml.bind.v2.schemagen.episode,
+ com.sun.xml.bind.v2.schemagen.xmlschema,
+ com.sun.xml.bind.v2.util,
+ jp.go.aist.rtm.toolscommon.profiles.util;uses:="junit.framework",
+ org.openrtp.namespaces.deploy,
+ org.openrtp.namespaces.rtc.version01;uses:="javax.xml.bind,javax.xml.datatype",
+ org.openrtp.namespaces.rtc.version02;uses:="javax.xml.bind,javax.xml.datatype",
+ org.openrtp.namespaces.rts.version01;uses:="javax.xml.bind,javax.xml.datatype",
+ org.openrtp.namespaces.rts.version02;uses:="javax.xml.bind,javax.xml.datatype",
+ org.slf4j
 Bundle-ActivationPolicy: lazy
 Eclipse-BuddyPolicy: registered
 Built-By: ngd

Modified: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/build.properties
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/build.properties	2016-02-20 17:38:11 UTC (rev 545)
+++ trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/build.properties	2016-02-20 17:38:34 UTC (rev 546)
@@ -10,7 +10,10 @@
                lib/jyaml-1.3.jar,\
                lib/jaxb-impl.jar,\
                jyaml.yml,\
-               schema/
+               schema/,\
+               lib/slf4j-api-1.7.13.jar,\
+               lib/logback-classic-1.1.3.jar,\
+               lib/logback-core-1.1.3.jar
 jars.compile.order = .
 source.. = src/
 output.. = bin/

Added: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/logback-classic-1.1.3.jar
===================================================================
(Binary files differ)


Property changes on: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/logback-classic-1.1.3.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/logback-core-1.1.3.jar
===================================================================
(Binary files differ)


Property changes on: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/logback-core-1.1.3.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/slf4j-api-1.7.13.jar
===================================================================
(Binary files differ)


Property changes on: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/lib/slf4j-api-1.7.13.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/LoggerUtil.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/LoggerUtil.java	                        (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/LoggerUtil.java	2016-02-20 17:38:34 UTC (rev 546)
@@ -0,0 +1,92 @@
+package jp.go.aist.rtm.toolscommon.profiles.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.util.StatusPrinter;
+
+/**
+ * ロギングの初期設定ユーティリティ
+ */
+public class LoggerUtil {
+
+	private static final Logger LOGGER = LoggerFactory
+			.getLogger(LoggerUtil.class);
+
+	private static final String DEFAULT_LOGBACK_XML = "./logback.xml";
+
+	private static LoggerContext context = null;
+
+	/**
+	 * ロギングの設定を行います。
+	 * <ul>
+	 * <li>すでに設定済の場合はスキップ</li>
+	 * <li>logback.xmlが存在しない場合は、デフォルトの設定ファイルを作成(カレントディレクトリ)</li>
+	 * <li>デフォルトの設定ファイルを読み込み、設定を反映</li>
+	 * </ul>
+	 */
+	public static synchronized void setup() {
+		if (context != null) {
+			LOGGER.info("setup: already setup logger.");
+			return;
+		}
+		setupConfigurationFile();
+		context = (LoggerContext) LoggerFactory.getILoggerFactory();
+		try {
+			JoranConfigurator configurator = new JoranConfigurator();
+			configurator.setContext(context);
+			context.reset();
+			configurator.doConfigure(DEFAULT_LOGBACK_XML);
+		} catch (JoranException e) {
+			System.err.println("Fail to configure by default");
+			e.printStackTrace(System.err);
+		}
+		StatusPrinter.print(context);
+	}
+
+	private static void setupConfigurationFile() {
+		File xml = new File(DEFAULT_LOGBACK_XML);
+		if (xml.exists()) {
+			return;
+		}
+		final String LOGBACK_XML_CONTENT = //
+		"<configuration>\r\n" //
+				+ "\r\n" //
+				+ "	<appender name=\"file\" class=\"ch.qos.logback.core.FileAppender\">\r\n" //
+				+ "		<file>${user.home}/openrtp.log</file>\r\n" //
+				+ "		<append>true</append>\r\n" //
+				+ "		<encoder>\r\n" //
+				+ "			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\r\n" //
+				+ "			</pattern>\r\n" //
+				+ "		</encoder>\r\n" //
+				+ "	</appender>\r\n" //
+				+ "\r\n" //
+				+ "	<appender name=\"stdout\" class=\"ch.qos.logback.core.ConsoleAppender\">\r\n" //
+				+ "		<encoder>\r\n" //
+				+ "			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\r\n" //
+				+ "			</pattern>\r\n" //
+				+ "		</encoder>\r\n" //
+				+ "	</appender>\r\n" //
+				+ "\r\n" //
+				+ "	<root level=\"trace\">\r\n" //
+				+ "		<appender-ref ref=\"stdout\" />\r\n" //
+				+ "		<appender-ref ref=\"file\" />\r\n" //
+				+ "	</root>\r\n" + "\r\n" //
+				+ "</configuration>\r\n";
+
+		try {
+			Files.write(xml.toPath(), LOGBACK_XML_CONTENT.getBytes());
+		} catch (IOException e) {
+			System.err.println("Fail to create logback.xml");
+			e.printStackTrace(System.err);
+		}
+	}
+
+}


Property changes on: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/LoggerUtil.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/XmlHandler.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/XmlHandler.java	2016-02-20 17:38:11 UTC (rev 545)
+++ trunk/rtmtools/jp.go.aist.rtm.toolscommon.profiles/src/jp/go/aist/rtm/toolscommon/profiles/util/XmlHandler.java	2016-02-20 17:38:34 UTC (rev 546)
@@ -85,6 +85,8 @@
 import org.openrtp.namespaces.rts.version02.TargetExecutioncontext;
 import org.openrtp.namespaces.rts.version02.TargetPortExt;
 import org.openrtp.namespaces.rts.version02.Waittime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -92,8 +94,11 @@
 
 public class XmlHandler {
 	
+	private static final Logger LOGGER = LoggerFactory
+			.getLogger(XmlHandler.class);
+	
 	public RtsProfileExt loadXmlRts(String targetFile) throws Exception {
-		
+		LOGGER.debug("loadXmlRts: targetFile=<{}>", targetFile);
 		StringBuffer stbRet = new StringBuffer();
 		InputStreamReader isr = new InputStreamReader(new FileInputStream(targetFile), "UTF-8");
 		BufferedReader br = new BufferedReader(isr);



More information about the openrtm-commit mailing list