Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Trying to make logging work
[QVTO] Trying to make logging work [message #480617] Mon, 17 August 2009 22:52 Go to next message
Derek Palma is currently offline Derek PalmaFriend
Messages: 141
Registered: July 2009
Senior Member
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 #480685 is a reply to message #480617] Tue, 18 August 2009 07:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

I'm interested in that, too.
Re: [QVTO] Trying to make logging work [message #480833 is a reply to message #480617] Tue, 18 August 2009 15:52 Go to previous messageGo to next message
Eclipse UserFriend
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 21:35 Go to previous message
Derek Palma is currently offline Derek PalmaFriend
Messages: 141
Registered: July 2009
Senior Member
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;
>>
>> }
>>
>
Previous Topic:[QVTO]QVTO newbie needs some help here.. :(
Next Topic:ATL: error in called rule
Goto Forum:
  


Current Time: Thu Apr 25 07:02:55 GMT 2024

Powered by FUDForum. Page generated in 0.02681 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top