1 33 34 package com.internetcds.util; 35 36 import java.io.*; 37 38 39 45 public class Logger 46 { 47 public static final String cvsVersion = "$Id: Logger.java,v 1.1 2006/06/23 10:39:30 sinisa Exp $"; 48 49 private static String filename = "log.out"; 50 private static boolean active = false; 51 private static PrintStream out = null; 52 53 64 synchronized private static void init() 65 throws IOException 66 { 67 if (out==null) 69 { 70 out = new PrintStream(new FileOutputStream(filename)); 72 } 73 } 74 75 83 synchronized public static void setActive(boolean value) 84 throws IOException 85 { 86 init(); 87 active = value; 88 } 89 90 93 public static boolean isActive() 94 { 95 return active; 96 } 97 98 107 public synchronized static void setFilename(String value) 108 { 109 filename = value; 110 } 111 112 115 public static String getFilename() 116 { 117 return filename; 118 } 119 120 123 synchronized public static void print(String msg) 124 throws IOException 125 { 126 if (active) 127 { 128 init(); 129 out.print(msg); 130 } 131 } 132 133 136 synchronized public static void println(String msg) 137 throws IOException 138 { 139 if (active) 140 { 141 init(); 142 out.println(msg); 143 } 144 } 145 } 146 | Popular Tags |