After several tries I've got the desired result with

//#if ($debug)\
log.finest("my useful debug message");
//#end\

But probably there is a nicer way to do the same thing. I am not an
expert in Velocity.


2006/6/2, Soeren Strassfeld <[EMAIL PROTECTED]>:
At least, you have to be very careful.
Just had a simple test
where
 public static void main(String[] args){
 //#if (true)
   System.out.println("logging");
 //#end
 }
was merged to
 public static void main(String[] args){
 //    System.out.println("logging");
 //  }

Soeren

(who thanks Geir every day for velocity ;)

Geir Magnusson Jr schrieb:
> Prove it.
>
> geir
>
> (who wrote a significant portion of velocity...)
>
>
>
> Soeren Strassfeld wrote:
>
>> That´s true, of course!
>>
>> Alexei Zakharov schrieb:
>>
>>> I worry about the situation when we got something Velocity-like in
>>> java code. Strings like "#foreach" or smth. like it in comments. This
>>> will probably break the V. compiler.
>>>
>>> 2006/6/1, Soeren Strassfeld <[EMAIL PROTECTED]>:
>>>
>>>> Hi Alexei,
>>>>
>>>> I think the result in both examples is quite the same, I just liked
>>>> the Idea to just add java comments to the code, so you don´t
>>>> need a precompiler as long as you build the classlib with logging
>>>> statements.
>>>>
>>>> Cheers,
>>>>  Soeren
>>>>
>>>> Alexei Zakharov schrieb:
>>>>
>>>>> Hi Soeren,
>>>>>
>>>>> 2006/6/1, Soeren Strassfeld <[EMAIL PROTECTED]>:
>>>>>
>>>>>> How about using Velocity as Preprocessor.
>>>>>> You could put all logging Statements between an
>>>>>> //#if ($debug)
>>>>>> and
>>>>>> //#end
>>>>>> So the Code would stay pure java, and the debug Version could be
>>>>>> compiled
>>>>>> without a Preprocessor.
>>>>>>
>>>>> Is this something better than just using java in the same way?
>>>>>
>>>>> static final boolean DEBUG = false;
>>>>> if (DEBUG) {
>>>>>    // wiped away by java compiler
>>>>>    log("my useful log message");
>>>>> }
>>>>>
>>>>> The problem of your approach as well as the above example is the
>>>>> additional syntax you need to add to each log call.
>>>>>
>>>>> However, I like the general idea of using Velocity as a Java
>>>>>
>>>> preprocessor
>>>>
>>>>> :)

--
Alexei Zakharov,
Intel Middleware Product Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to