velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Re: EventCartridge
Date Tue, 17 Jul 2001 03:05:33 GMT
Brian Lloyd-Newberry wrote:
> Hey All,
>     Frequently in processor that I am writing/using I need to be able
> to give users (i.e. me) a "intelligent" message in regards to what is
> happening when there are null references or other velocity odditities
> in their templates.
>     Right now I can use an EventCartridge to catch a NullSetEvent or a
> MethodExceptionEvent, but I am at a loss as to how to make use of the
> event to display a line and resource identifier so the user can fix
> their problem. As I see the code it is not possible to get information
> relative to the node that an event came from (where I could get the
> line and column) and even if i had a node get the resource it was
> parsed from.

Yes, that's something we didn't think of when we did it.  I think the
general feeling was to make it more for runtime use, but this certainly
is valid.


I read the message a while ago when I got home, and have been stewing
over it... makes me wonder what to do other than tell you to read the

(Sorry, I couldn't resist the last part :)

>     The "look in the velocity log" argument is not really an option for
> writing a viable tool as far as I see it for several reasons. Is this
> something that would be desirable to others? Is this the intention of
> the EventCartridge? It seems like an Event in the Cartridge should
> contain the source node for the event. I would be willing to look at
> the code and "work on it" unless I get screamed down. :)

No, looking at the log isn't that hip for your use, I suppose, although
it's easy for you to implement a custom logger so you get the log
messages programatically.  I don't know if that would help.  Take a look
at the ExternalLoggerTest test case (org.apache.velocity.test) or the
logger_example in /examples.  And read the docs too.

(aw, sorry, did it again...)

The intention of the EventCartridge was to handle runtime issues, such
as escaping XML on insertion into the stream, catching exceptions when a
method invoked by the template threw one, or squelching log messages
that the programmer didn't care about.  Very runtime-ish/production-ish
issues. It wasn't really intended to be a diagnostic tool like this for
development, mainly because we felt that the runtime features were
needed, and you could look at the log :)

I wonder if you could combine the features of the external logger with
that of the event firings...

Hmmm. Ah!  How about this - we work out some way where the event
cartridge you are attached to will tell you information about the
current event.  That way, we don't have to spooge the interfaces...

I'll see if I can sketch something out and post it.

>     Another issue is that sometimes I get messed up line numbers or
> line numbers without reference to a resource in the log when something
> funky happens. Usually I am merging multiple resources one after
> another in the same Velocity instance with the same Context. Is this a
> known issue? I can probably come up with test cases to show it
> happening if need be.

Yes please.  That would be great!


Geir Magnusson Jr.                 
System and Software Consulting
Developing for the web?  See
You have a genius for suggesting things I've come a cropper with!

View raw message