[QVTO] Trying to make logging work [message #480617] |
Mon, 17 August 2009 18:52  |
Eclipse User |
|
|
|
Hi,
I am executing QVT transformations from Java and having problems setting up
logging.
I used the following example transformation:
transformation TestLog();
main() {
var s := "foo";
log ("log output: ", s) when true;
}
Below is the Java code I use to execute the transformation. I expect to see
the log messages appear on the console output but nothing is ever printed.
It makes me wonder if the transformation is ever executed. However, the code
does take the Diagnostic.OK indicating the execution complete without
errors. I presume my problem is in the way I am invoking the
transformation.
Any insight would be appreciated.
Thanks,
Derek
public static List<EObject> transform(URI transformationURI, List<EObject>
contextList) {
TransformationExecutor executor = new
TransformationExecutor(transformationURI);
System.out.println("Input size: " + contextList.size());
ModelExtent input = new BasicModelExtent(contextList);
ModelExtent output = new BasicModelExtent();
ExecutionContextImpl context = new ExecutionContextImpl();
// context.setConfigProperty("keepModeling", true);
context.setLog(new WriterLog(new PrintWriter(System.out)));
ExecutionDiagnostic diagnostic = executor.execute(context/*, input,
output*/);
if(diagnostic.getSeverity() == Diagnostic.OK) {
List<EObject> outputList = output.getContents();
System.out.println("Output size: " + outputList.size());
return outputList;
} else {
IStatus status = BasicDiagnostic.toIStatus(diagnostic);
String message = status.getMessage();
System.out.println("transform failure: " + message);
// InvokeActivator.getDefault().getLog().log(status);
}
return null;
}
|
|
|
|
Re: [QVTO] Trying to make logging work [message #480833 is a reply to message #480617] |
Tue, 18 August 2009 11:52   |
Eclipse User |
|
|
|
Originally posted by: dvorak.radek.gmail.com
Hi Derek,
I suspect that not flushing the PrintWriter, which wraps the System.out
might be the reason.
You can also test with org.eclipse.m2m.qvt.oml.util.StringBufferLog or
provide
whatever custom logger by implementing org.eclipse.m2m.qvt.oml.util.Log.
Regards,
/Radek
On Tue, 18 Aug 2009 00:52:01 +0200, Derek Palma <derek.palma@gmail.com>
wrote:
> Hi,
>
> I am executing QVT transformations from Java and having problems setting
> up logging.
>
> I used the following example transformation:
>
> transformation TestLog();
>
>
> main() {
>
> var s := "foo";
>
> log ("log output: ", s) when true;
>
> }
>
>
> Below is the Java code I use to execute the transformation. I expect to
> see the log messages appear on the console output but nothing is ever
> printed. It makes me wonder if the transformation is ever executed.
> However, the code does take the Diagnostic.OK indicating the execution
> complete without errors. I presume my problem is in the way I am
> invoking the transformation.
>
> Any insight would be appreciated.
>
> Thanks,
> Derek
>
>
> public static List<EObject> transform(URI transformationURI,
> List<EObject> contextList) {
>
>
> TransformationExecutor executor = new
> TransformationExecutor(transformationURI);
>
>
> System.out.println("Input size: " + contextList.size());
>
>
> ModelExtent input = new BasicModelExtent(contextList);
>
> ModelExtent output = new BasicModelExtent();
>
>
> ExecutionContextImpl context = new ExecutionContextImpl();
>
> // context.setConfigProperty("keepModeling", true);
>
> context.setLog(new WriterLog(new PrintWriter(System.out)));
>
>
> ExecutionDiagnostic diagnostic = executor.execute(context/*, input,
> output*/);
>
>
> if(diagnostic.getSeverity() == Diagnostic.OK) {
>
> List<EObject> outputList = output.getContents();
>
> System.out.println("Output size: " + outputList.size());
>
> return outputList;
>
> } else {
>
> IStatus status = BasicDiagnostic.toIStatus(diagnostic);
>
> String message = status.getMessage();
>
> System.out.println("transform failure: " + message);
>
> // InvokeActivator.getDefault().getLog().log(status);
>
> }
>
>
> return null;
>
> }
>
|
|
|
Re: [QVTO] Trying to make logging work [message #480912 is a reply to message #480833] |
Tue, 18 August 2009 17:35  |
Eclipse User |
|
|
|
Thanks Radek!
Not flushing the PrintWriter was the problem.
Derek
"radek dvorak" <dvorak.radek@gmail.com> wrote in message
news:op.uyu7qc0r12y5f2@kliste.local...
> Hi Derek,
>
> I suspect that not flushing the PrintWriter, which wraps the System.out
> might be the reason.
> You can also test with org.eclipse.m2m.qvt.oml.util.StringBufferLog or
> provide
> whatever custom logger by implementing org.eclipse.m2m.qvt.oml.util.Log.
> Regards,
> /Radek
>
>
> On Tue, 18 Aug 2009 00:52:01 +0200, Derek Palma <derek.palma@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am executing QVT transformations from Java and having problems setting
>> up logging.
>>
>> I used the following example transformation:
>>
>> transformation TestLog();
>>
>>
>> main() {
>>
>> var s := "foo";
>>
>> log ("log output: ", s) when true;
>>
>> }
>>
>>
>> Below is the Java code I use to execute the transformation. I expect to
>> see the log messages appear on the console output but nothing is ever
>> printed. It makes me wonder if the transformation is ever executed.
>> However, the code does take the Diagnostic.OK indicating the execution
>> complete without errors. I presume my problem is in the way I am
>> invoking the transformation.
>>
>> Any insight would be appreciated.
>>
>> Thanks,
>> Derek
>>
>>
>> public static List<EObject> transform(URI transformationURI,
>> List<EObject> contextList) {
>>
>>
>> TransformationExecutor executor = new
>> TransformationExecutor(transformationURI);
>>
>>
>> System.out.println("Input size: " + contextList.size());
>>
>>
>> ModelExtent input = new BasicModelExtent(contextList);
>>
>> ModelExtent output = new BasicModelExtent();
>>
>>
>> ExecutionContextImpl context = new ExecutionContextImpl();
>>
>> // context.setConfigProperty("keepModeling", true);
>>
>> context.setLog(new WriterLog(new PrintWriter(System.out)));
>>
>>
>> ExecutionDiagnostic diagnostic = executor.execute(context/*, input,
>> output*/);
>>
>>
>> if(diagnostic.getSeverity() == Diagnostic.OK) {
>>
>> List<EObject> outputList = output.getContents();
>>
>> System.out.println("Output size: " + outputList.size());
>>
>> return outputList;
>>
>> } else {
>>
>> IStatus status = BasicDiagnostic.toIStatus(diagnostic);
>>
>> String message = status.getMessage();
>>
>> System.out.println("transform failure: " + message);
>>
>> // InvokeActivator.getDefault().getLog().log(status);
>>
>> }
>>
>>
>> return null;
>>
>> }
>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.05460 seconds