Skip to content

Commit 9e73288

Browse files
committed
Added logging
1 parent e654711 commit 9e73288

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateFacade.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.fugerit.java.core.function.SafeFunction;
1313
import org.fugerit.java.core.io.StreamIO;
1414
import org.fugerit.java.core.lang.helpers.StringUtils;
15+
import org.fugerit.java.core.util.checkpoint.SimpleCheckpoint;
1516
import org.fugerit.java.doc.base.config.DocInput;
1617
import org.fugerit.java.doc.base.config.DocOutput;
1718
import org.fugerit.java.doc.base.config.DocTypeHandler;
@@ -49,9 +50,11 @@ public class GenerateFacade {
4950

5051
private void doHandle( DocTypeHandler handler, String type, int sourceType, Reader reader, ByteArrayOutputStream baos ) {
5152
SafeFunction.apply( () -> {
53+
SimpleCheckpoint checkpoint = new SimpleCheckpoint();
5254
DocInput docInput = DocInput.newInput( type, reader , sourceType );
5355
DocOutput docOutput = DocOutput.newOutput( baos );
5456
handler.handle(docInput, docOutput);
57+
log.info( "actual render, handler : {}, type : {}, sourceType : {}, time : {}", handler.getClass().getSimpleName(), type, sourceType, checkpoint.getFormatTimeDiffMillis() );
5558
} );
5659
}
5760

@@ -83,23 +86,30 @@ private void handleConfiguration( Configuration configuration, JsonNode node, St
8386
configuration.setTemplateExceptionHandler( TemplateExceptionHandler.RETHROW_HANDLER );
8487
configuration.setTemplateLoader( loader );
8588
}
86-
89+
8790
private void handleFtlx( DocTypeHandler handler, String type, int sourceType, Reader reader, ByteArrayOutputStream baos, String freemarkerJsonData ) {
8891
SafeFunction.apply( () -> {
92+
SimpleCheckpoint checkpoint = new SimpleCheckpoint();
8993
// volatile FreeMarker Template configuration
9094
String chainId = "current_"+System.currentTimeMillis();
9195
Configuration configuration = new Configuration( new Version( FreeMarkerConfigStep.ATT_FREEMARKER_CONFIG_KEY_VERSION_LATEST ) );
96+
log.info( "ftlx create configuration : {}", checkpoint.getFormatTimeDiffMillis() );
9297
ObjectMapper mapper = new ObjectMapper();
9398
try ( StringReader jsonReader = new StringReader(freemarkerJsonData) ) {
9499
JsonNode node = mapper.readTree( jsonReader ); // parse json node to sanitize input
100+
log.info( "read json : {}", checkpoint.getFormatTimeDiffMillis() );
95101
this.handleConfiguration(configuration, node, StreamIO.readString( reader ), chainId );
102+
log.info( "ftlx handle configuration : {}", checkpoint.getFormatTimeDiffMillis() );
96103
Template currentChain = configuration.getTemplate( chainId );
104+
log.info( "ftlx get template : {}", checkpoint.getFormatTimeDiffMillis() );
97105
Map<Object, Object> data = new HashMap<>();
98106
data.put( "messageFormat" , new SimpleMessageFun() );
99107
try ( StringWriter writer = new StringWriter() ) {
100108
currentChain.process( data , writer );
109+
log.info( "ftlx process chain : {}", checkpoint.getFormatTimeDiffMillis() );
101110
try ( StringReader ftlReader = new StringReader( writer.toString() ) ) {
102111
this.doHandle(handler, type, sourceType, ftlReader, baos);
112+
log.info( "ftlx render document : {}", checkpoint.getFormatTimeDiffMillis() );
103113
}
104114
}
105115
}
@@ -109,18 +119,27 @@ private void handleFtlx( DocTypeHandler handler, String type, int sourceType, Re
109119

110120
private void handleKts( DocTypeHandler handler, String type, Reader reader, ByteArrayOutputStream baos, String ktsJsonData ) {
111121
SafeFunction.apply( () -> {
122+
SimpleCheckpoint checkpoint = new SimpleCheckpoint();
112123
ScriptEngineManager manager = new ScriptEngineManager();
124+
log.info( "kts create script manager : {}", checkpoint.getFormatTimeDiffMillis() );
113125
ScriptEngine engine = manager.getEngineByExtension( "kts" );
126+
log.info( "kts create script engine : {}", checkpoint.getFormatTimeDiffMillis() );
114127
Bindings bindings = engine.createBindings();
128+
log.info( "kts create script bindings : {}", checkpoint.getFormatTimeDiffMillis() );
115129
ObjectMapper mapper = new ObjectMapper();
116130
try ( StringReader jsonReader = new StringReader(ktsJsonData) ) {
117131
LinkedHashMap data = mapper.readValue( jsonReader, LinkedHashMap.class );
132+
log.info( "kts read json data : {}", checkpoint.getFormatTimeDiffMillis() );
118133
bindings.put( "data", data );
119134
engine.setBindings( bindings, ScriptContext.ENGINE_SCOPE );
135+
log.info( "kts set bindings : {}", checkpoint.getFormatTimeDiffMillis() );
120136
Object obj = engine.eval( StreamIO.readString( reader ) );
137+
log.info( "kts eval script : {}", checkpoint.getFormatTimeDiffMillis() );
121138
String xml = obj.toString();
139+
log.info( "kts toXml : {}", checkpoint.getFormatTimeDiffMillis() );
122140
try ( StringReader xmlReader = new StringReader( xml) ) {
123141
this.doHandle(handler, type, DocFacadeSource.SOURCE_TYPE_XML, xmlReader, baos);
142+
log.info( "kts render document : {}", checkpoint.getFormatTimeDiffMillis() );
124143
}
125144
}
126145
} );

0 commit comments

Comments
 (0)