java_gen: add optional instrumentation
diff --git a/java_gen/templates/of_class.java b/java_gen/templates/of_class.java
index 7b3b762..ee38beb 100644
--- a/java_gen/templates/of_class.java
+++ b/java_gen/templates/of_class.java
@@ -38,6 +38,9 @@
//:: include("_imports.java", msg=msg)
class ${impl_class} implements ${msg.interface.inherited_declaration()} {
+//:: if genopts.instrument:
+ private static final Logger logger = LoggerFactory.getLogger(${impl_class}.class);
+//:: #endif
// version: ${version}
final static byte WIRE_VERSION = ${version.int_version};
//:: if msg.is_fixed_length:
@@ -216,6 +219,11 @@
bb.readerIndex(start);
return null;
}
+ //:: if genopts.instrument:
+ if(OFInstrumentationOptions.TRACE_READS)
+ if(logger.isTraceEnabled())
+ logger.trace("readFrom - length={}", ${prop.name});
+ //:: #endif
//:: elif prop.is_fixed_value:
// fixed value property ${prop.name} == ${prop.value}
${prop.java_type.priv_type} ${prop.name} = ${prop.java_type.read_op(version, pub_type=False)};
@@ -242,11 +250,22 @@
//:: if os.path.exists("%s/custom/%s.Reader_normalize_stanza.java" % (template_dir, msg.name)):
//:: include("custom/%s.Reader_normalize_stanza.java" % msg.name, msg=msg, has_parent=False)
//:: #endif
- return new ${impl_class}(
+ ${impl_class} ${msg.variable_name} = new ${impl_class}(
${",\n ".join(
[ prop.name for prop in msg.data_members])}
);
+ //:: if genopts.instrument:
+ if(OFInstrumentationOptions.TRACE_READS)
+ if(logger.isTraceEnabled())
+ logger.trace("readFrom - read={}", ${msg.variable_name});
+ //:: #endif
+ return ${msg.variable_name};
//:: else:
+ //:: if genopts.instrument:
+ if(OFInstrumentationOptions.TRACE_READS)
+ if(logger.isTraceEnabled())
+ logger.trace("readFrom - returning shared instance={}", INSTANCE);
+ //:: #endif
return INSTANCE;
//:: #endif
}