001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.object.logging;
005:
006: import com.tc.logging.CustomerLogging;
007: import com.tc.logging.TCLogger;
008: import com.tc.object.config.LockDefinition;
009: import com.tc.object.config.schema.DSOInstrumentationLoggingOptions;
010:
011: import java.util.Collection;
012: import java.util.Iterator;
013:
014: public class InstrumentationLoggerImpl implements InstrumentationLogger {
015:
016: private final DSOInstrumentationLoggingOptions opts;
017: private final TCLogger logger;
018:
019: public InstrumentationLoggerImpl(
020: DSOInstrumentationLoggingOptions opts) {
021: this .opts = opts;
022: this .logger = CustomerLogging.getDSOInstrumentationLogger();
023: }
024:
025: public boolean classInclusion() {
026: return opts.logClass().getBoolean();
027: }
028:
029: public boolean lockInsertion() {
030: return opts.logLocks().getBoolean();
031: }
032:
033: public boolean transientRootWarning() {
034: return opts.logTransientRoot().getBoolean();
035: }
036:
037: public boolean rootInsertion() {
038: return opts.logRoots().getBoolean();
039: }
040:
041: public boolean distMethodCallInsertion() {
042: return opts.logDistributedMethods().getBoolean();
043: }
044:
045: public void classIncluded(String className) {
046: logger.info(className + " included for instrumentation");
047: }
048:
049: public void subclassOfLogicallyManagedClasses(String className,
050: Collection logicalSuperClasses) {
051: StringBuffer buffer = new StringBuffer();
052: buffer.append(className).append(
053: " is a subclass of a logically managed superclass : (");
054:
055: for (Iterator i = logicalSuperClasses.iterator(); i.hasNext();) {
056: buffer.append(i.next());
057: if (i.hasNext()) {
058: buffer.append(',');
059: }
060: }
061:
062: buffer
063: .append("). This is currently not supported! Perhaps it has overridden a protected method.");
064: logger.warn(buffer.toString());
065:
066: }
067:
068: public void autolockInserted(String className, String methodName,
069: String methodDesc, LockDefinition lockDefinition) {
070: String level = lockDefinition.getLockLevel().toString();
071: logger.info("Inserting autolocks in method " + className + "."
072: + methodName + methodDesc + ", level: " + level);
073: }
074:
075: public void lockInserted(String className, String methodName,
076: String methodDesc, LockDefinition[] locks) {
077: StringBuffer sb = new StringBuffer();
078:
079: String s = locks.length > 1 ? "locks" : "lock";
080:
081: sb.append("Inserting named ").append(s).append(" in ").append(
082: className).append('.').append(methodName).append(
083: methodDesc);
084: for (int i = 0; i < locks.length; i++) {
085: sb.append("\n\tname: ").append(locks[i].getLockName())
086: .append(", level: ")
087: .append(locks[i].getLockLevel());
088: }
089:
090: logger.info(sb.toString());
091: }
092:
093: public void transientRootWarning(String className, String fieldName) {
094: logger
095: .warn("The java transient property is being ignored for root:"
096: + className + "." + fieldName);
097: }
098:
099: public void rootInserted(String className, String fieldName,
100: String desc, boolean isStatic) {
101: logger.info("DSO root inserted for field " + className + "."
102: + fieldName + ", type " + (isStatic ? "static " : "")
103: + desc);
104: }
105:
106: public void distMethodCallInserted(String className,
107: String methodName, String desc) {
108: logger.info("Adding distributed call: " + methodName + desc
109: + " to class:" + className);
110: }
111:
112: }
|