Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

OpenMSPServiceTracer.java

00001 /*
00002  *        OpenMobileIS - a free Java Framework for mobile applications
00003  *
00004  *   Copyright (C) 2002  Philippe Delrieu.
00005  *
00006  *   This program is free software; you can redistribute it and/or
00007  *   modify it under the terms of the GNU General Public
00008  *   License as published by the Free Software Foundation; either
00009  *   version 2 of the License, or (at your option) any later version.
00010  *
00011  *   This program is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *   General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU Library General Public
00017  *   License along with this library; if not, write to the Free
00018  *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  * 
00020  * Philippe Delrieu kept the rigth to distribute all code Copyrighted by philippe Delrieu
00021  *  under other licence term even commercial one.
00022  *  
00023  *  Modifications :
00024  *  2002 Creation P.Delrieu
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 }

Generated on Wed Dec 14 21:05:34 2005 for OpenMobileIS by  doxygen 1.4.4