1 package org.apache.velocity.runtime.log; 2 3 18 19 import java.util.Vector ; 20 import java.util.Enumeration ; 21 22 import org.apache.velocity.runtime.RuntimeServices; 23 24 33 public class PrimordialLogSystem implements LogSystem 34 { 35 private Vector pendingMessages = new Vector (); 36 private RuntimeServices rsvc = null; 37 38 41 public PrimordialLogSystem() 42 { 43 } 44 45 public void init( RuntimeServices rs ) 46 throws Exception 47 { 48 rsvc = rs; 49 } 50 51 58 public void logVelocityMessage(int level, String message) 59 { 60 synchronized( this ) 61 { 62 Object [] data = new Object [2]; 63 data[0] = new Integer (level); 64 data[1] = message; 65 pendingMessages.addElement(data); 66 } 67 } 68 69 72 public void dumpLogMessages( LogSystem newLogger ) 73 { 74 synchronized( this ) 75 { 76 if ( !pendingMessages.isEmpty()) 77 { 78 81 82 for( Enumeration e = pendingMessages.elements(); e.hasMoreElements(); ) 83 { 84 Object [] data = (Object []) e.nextElement(); 85 newLogger.logVelocityMessage(((Integer ) data[0]).intValue(), (String ) data[1]); 86 } 87 } 88 } 89 } 90 } 91 | Popular Tags |