add logging

This commit is contained in:
Volker Berlin 2019-07-19 22:29:34 +02:00
parent c2b8505634
commit e37caf06b1
3 changed files with 32 additions and 0 deletions

View File

@ -25,6 +25,12 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.StreamHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -73,6 +79,26 @@ public class JWebAssembly {
*/ */
public static final String REPLACE_ANNOTATION = "de.inetsoftware.jwebassembly.api.annotation.Replace"; public static final String REPLACE_ANNOTATION = "de.inetsoftware.jwebassembly.api.annotation.Replace";
/**
* The logger instance
*/
public static final Logger LOGGER = Logger.getAnonymousLogger( null );
static {
LOGGER.setUseParentHandlers( false );
ConsoleHandler handler = new ConsoleHandler() {{
setOutputStream(System.out);
}};
handler.setFormatter( new Formatter() {
@Override
public String format( LogRecord record ) {
return record.getMessage() + '\n';
}
});
handler.setLevel( Level.ALL );
LOGGER.addHandler( handler );
//LOGGER.setLevel( Level.FINE );
}
/** /**
* Create a instance. * Create a instance.
*/ */

View File

@ -162,14 +162,17 @@ public class ModuleGenerator {
ClassFile classFile = ClassFile.get( next.className, libraries ); ClassFile classFile = ClassFile.get( next.className, libraries );
if( classFile == null ) { if( classFile == null ) {
if( next instanceof SyntheticFunctionName ) { if( next instanceof SyntheticFunctionName ) {
JWebAssembly.LOGGER.info( '\t' + next.methodName + next.signature );
scanMethod( ((SyntheticFunctionName)next).getCodeBuilder( watParser ) ); scanMethod( ((SyntheticFunctionName)next).getCodeBuilder( watParser ) );
functions.markAsScanned( next ); functions.markAsScanned( next );
} }
} else { } else {
JWebAssembly.LOGGER.fine( "scan class: " + next.className );
iterateMethods( classFile, method -> { iterateMethods( classFile, method -> {
try { try {
FunctionName name = new FunctionName( method ); FunctionName name = new FunctionName( method );
if( functions.needToScan( name ) ) { if( functions.needToScan( name ) ) {
JWebAssembly.LOGGER.fine( '\t' + name.methodName + name.signature );
scanMethod( createInstructions( functions.replace( name, method ) ) ); scanMethod( createInstructions( functions.replace( name, method ) ) );
functions.markAsScanned( name ); functions.markAsScanned( name );
} }
@ -226,6 +229,7 @@ public class ModuleGenerator {
writeMethodSignature( name, functions.isStatic( name ), null ); writeMethodSignature( name, functions.isStatic( name ), null );
} }
JWebAssembly.LOGGER.fine( "scan finsih" );
types.prepareFinish( writer, functions, libraries ); types.prepareFinish( writer, functions, libraries );
prepareFunctions(); // prepare of types can add some override methods as needed prepareFunctions(); // prepare of types can add some override methods as needed
functions.prepareFinish(); functions.prepareFinish();

View File

@ -30,6 +30,7 @@ import de.inetsoftware.classparser.ClassFile;
import de.inetsoftware.classparser.ConstantClass; import de.inetsoftware.classparser.ConstantClass;
import de.inetsoftware.classparser.FieldInfo; import de.inetsoftware.classparser.FieldInfo;
import de.inetsoftware.classparser.MethodInfo; import de.inetsoftware.classparser.MethodInfo;
import de.inetsoftware.jwebassembly.JWebAssembly;
import de.inetsoftware.jwebassembly.WasmException; import de.inetsoftware.jwebassembly.WasmException;
import de.inetsoftware.jwebassembly.wasm.AnyType; import de.inetsoftware.jwebassembly.wasm.AnyType;
import de.inetsoftware.jwebassembly.wasm.NamedStorageType; import de.inetsoftware.jwebassembly.wasm.NamedStorageType;
@ -101,6 +102,7 @@ public class TypeManager {
public StructType valueOf( String name ) { public StructType valueOf( String name ) {
StructType type = map.get( name ); StructType type = map.get( name );
if( type == null ) { if( type == null ) {
JWebAssembly.LOGGER.fine( "\t\ttype: " + name );
type = new StructType( name ); type = new StructType( name );
map.put( name, type ); map.put( name, type );
} }