For the backend, I have the Tailer running in a Thread, and keep a reference to
it. The you can interrupt the thread as desired by calling thread.interrupt().
Some backend code you might find useful:
private Thread thread;
public void destroy() {
//set the flag to tell our listener to shutdown
stopListener();
}
public void startListener(File f) {
if(thread == null) {
//setup the listener and start the thread
TailerListener listener = new LogTailListener();
Tailer tailer = new Tailer(f, listener, 1000, true);
thread = new Thread(tailer, THREAD_NAME);
thread.start();
}
}
public void stopListener() {
thread.interrupt();
}
Interested to see your UI when you are done, please share!
cheers,
Steve
On 21/11/2011, at 3:10 PM, James wrote:
> Clint,
>
> Thanks for this idea. Let me give a try to it.
> Pondering whether the Tailer would introduce any memory leaks if we
> navigate to a different page.
>
> On Mon, Nov 21, 2011 at 11:46 AM, Clint Checketts <[email protected]>wrote:
>
>> I'd need to look at Tailer to see how it operates. But here is how I'd try
>> it (it is quick and I don't like the markup, but we'll optimize it later:
>>
>> Create a panel that looks like so (we'll call it LoggingPanel):
>>
>> <wicket:panel>
>> <div wicket:id="logData">log contents</div>
>> <div wicket:id="nextLog">next log call</div>
>> </wicket:panel>
>>
>> Add a self updating timer behavior so the panel check the Tailer for
>> output, if there is data, then update the logData label with it, make the
>> nextLog component be another LoggingPanel with a SelfUpdatingTImerBehavior,
>> and stop the timerbehavior on the current panel.
>>
>> Drawbacks are: the divs keep getting nested, so the markup isn't the most
>> beautiful, so setRenderBodyOnly(true) might make it nicer.
>>
>> -Clint
>>
>> On Sun, Nov 20, 2011 at 9:27 PM, James <[email protected]> wrote:
>>
>>> Thanks Steve. I'll look into the commons-io "Tailer".
>>> But any idea on how to use this with wicket?
>>>
>>> On Mon, Nov 21, 2011 at 11:10 AM, Steve Swinsburg <
>>> [email protected]
>>>> wrote:
>>>
>>>> I've done something similar to this using the Tailer class from
>>> commons-io.
>>>>
>>>> cheers,
>>>> Steve
>>>>
>>>>
>>>> On 21/11/2011, at 12:59 PM, James wrote:
>>>>
>>>>> Dear wicket community,
>>>>>
>>>>> In a project that I'm working on, I need to build a "live log viewer"
>>> or
>>>>> "dynamic log viewer" or "refreshable log viewer".
>>>>> Much like how hudson/jenkins displays the console output.
>>>>>
>>>>> The idea is to dynamically display the new data added to a log file
>>> along
>>>>> with the existing content.
>>>>>
>>>>> How to go about doing this? Please throw some light on this.
>>>>>
>>>>> I searched about this in the web, mailing lists but couldn't find
>> what
>>> I
>>>>> was looking for, so I'm posting it here.
>>>>> If this is asked elsewhere, kindly re-direct me to the respective
>>>> resource.
>>>>>
>>>>> --
>>>>> Thanks & Regards,
>>>>> James
>>>>> A happy Wicket user
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>>
>>> --
>>> Thanks & Regards,
>>> James
>>>
>>
>
>
>
> --
> Thanks & Regards,
> James