1 4 package com.tc.object.logging; 5 6 import com.tc.logging.CustomerLogging; 7 import com.tc.logging.TCLogger; 8 import com.tc.object.config.LockDefinition; 9 import com.tc.object.config.schema.DSOInstrumentationLoggingOptions; 10 11 import java.util.Collection ; 12 import java.util.Iterator ; 13 14 public class InstrumentationLoggerImpl implements InstrumentationLogger { 15 16 private final DSOInstrumentationLoggingOptions opts; 17 private final TCLogger logger; 18 19 public InstrumentationLoggerImpl(DSOInstrumentationLoggingOptions opts) { 20 this.opts = opts; 21 this.logger = CustomerLogging.getDSOInstrumentationLogger(); 22 } 23 24 public boolean classInclusion() { 25 return opts.logClass().getBoolean(); 26 } 27 28 public boolean lockInsertion() { 29 return opts.logLocks().getBoolean(); 30 } 31 32 public boolean transientRootWarning() { 33 return opts.logTransientRoot().getBoolean(); 34 } 35 36 public boolean rootInsertion() { 37 return opts.logRoots().getBoolean(); 38 } 39 40 public boolean distMethodCallInsertion() { 41 return opts.logDistributedMethods().getBoolean(); 42 } 43 44 public void classIncluded(String className) { 45 logger.info(className + " included for instrumentation"); 46 } 47 48 public void subclassOfLogicallyManagedClasses(String className, Collection logicalSuperClasses) { 49 StringBuffer buffer = new StringBuffer (); 50 buffer.append(className).append(" is a subclass of a logically managed superclass : ("); 51 52 for (Iterator i = logicalSuperClasses.iterator(); i.hasNext();) { 53 buffer.append(i.next()); 54 if (i.hasNext()) { 55 buffer.append(','); 56 } 57 } 58 59 buffer.append("). This is currently not supported! Perhaps it has overridden a protected method."); 60 logger.warn(buffer.toString()); 61 62 } 63 64 public void autolockInserted(String className, String methodName, String methodDesc, LockDefinition lockDefinition) { 65 String level = lockDefinition.getLockLevel().toString(); 66 logger.info("Inserting autolocks in method " + className + "." + methodName + methodDesc + ", level: " + level); 67 } 68 69 public void lockInserted(String className, String methodName, String methodDesc, LockDefinition[] locks) { 70 StringBuffer sb = new StringBuffer (); 71 72 String s = locks.length > 1 ? "locks" : "lock"; 73 74 sb.append("Inserting named ").append(s).append(" in ").append(className).append('.').append(methodName) 75 .append(methodDesc); 76 for (int i = 0; i < locks.length; i++) { 77 sb.append("\n\tname: ").append(locks[i].getLockName()).append(", level: ").append(locks[i].getLockLevel()); 78 } 79 80 logger.info(sb.toString()); 81 } 82 83 public void transientRootWarning(String className, String fieldName) { 84 logger.warn("The java transient property is being ignored for root:" + className + "." + fieldName); 85 } 86 87 public void rootInserted(String className, String fieldName, String desc, boolean isStatic) { 88 logger.info("DSO root inserted for field " + className + "." + fieldName + ", type " + (isStatic ? "static " : "") 89 + desc); 90 } 91 92 public void distMethodCallInserted(String className, String methodName, String desc) { 93 logger.info("Adding distributed call: " + methodName + desc + " to class:" + className); 94 } 95 96 } 97 | Popular Tags |