00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package org.openmobileis.synchro.openmsp.server;
00029
00030 import java.io.FileOutputStream;
00031 import java.io.PrintStream;
00032 import java.util.Properties;
00033
00034 import org.openmobileis.common.util.log.FileLogTracer;
00035
00043 public class OpenMSPServiceTracer extends FileLogTracer {
00044 private java.text.SimpleDateFormat formatter;
00045
00046 public OpenMSPServiceTracer() {
00047 super();
00048 formatter = new java.text.SimpleDateFormat ("[dd/MMM/yyyy:HH:mm:ss]", java.util.Locale.FRANCE);
00049 }
00050
00057 public void setLogTracerProperties(Properties props) {
00058 try {
00059 logFile = props.getProperty("LOGFILE");
00060 if (logFile == null) {
00061 System.out.println("LOGFILE property is not defined for OpenMSPServiceTracer");
00062 System.out.println("LOG to console");
00063 outStream = System.out;
00064 return;
00065 }
00066
00067 } catch (Exception e) {
00068 System.out.println("Error in FileTraceManager Init" +e);
00069 }
00070 }
00074 public void trace(int service, int priority, String message) {
00075 try {
00076 fileStream = new FileOutputStream(logFile, true);
00077 try {
00078 outStream = new PrintStream(fileStream, true);
00079 outStream.print(formatter.format(new java.util.Date())
00080 +"-"+message
00081 +"\n");
00082 outStream.flush();
00083 } catch (Throwable ex) {
00084 System.out.println("Error in OpenMSPServiceTracer trace" +ex);
00085 } finally {
00086 fileStream.close();
00087 }
00088 } catch (Throwable ex) {
00089 System.out.println("Error in OpenMSPServiceTracer trace" +ex);
00090 }
00091 }
00092 }