Do you think the logger would easily be able to log instead to the localStorage rather than the console?
Perhaps then the viewer portion could have a listener to localStorage changes and refreshing it’s store?
This way a second debug browser tab would be able to persist the log across page loads.
Perhaps a controller object could watch and prune the localStorage to ‘occurrence’ and ‘duration’ limit settings per category?
Is this close to where your headed with the code?
Does is sound viable?
Writing logs to local storage should be relatively easy to do, as log4js-ext is architected with this kind of extension in mind. You need to write your own appender, deriving it from AppenderBase, and register it the same way you register other appenders (think of the standard LogViewerAppender).
Originally Posted by theschafergroup
Appenders are in charge of sending log messages to the final destination, be it the browser console, the built-in viewer, a remote server or local storage. You will be able to write your own appender by taking a look at the ExtLogAppender and LogViewerAppender implementations.
Viewing data stored in the local storage in the built in viewer will be a different business, as you will be handling old stored logs, not logs as they are created, which is what the viewer is written for.
Anyway, as an idea, you might get what you want by a) creating an appender inheriting from LogViewerAppender that writes logs both to the built-in viewer and the local storage. Then, b), you should create your own viewer inheriting from LogViewerWindow: whenever an instance is created, it will load old logs in the local storage, giving the appearance that the view has not been destroyed across pages, and new logs will be written both to the local storage and the viewer...
Connect you new appender and viewer, and voila, you should be able to use them the way you use the built-in viewer and appender.
Just a quick idea, other approaches will work too... But it looks relatively easy to do, as most functionality is already there, so you might want to give it a try.
BTW, handling logs across pages seems a useful use case for some users (not for my typical scenario, though), and I will consider adding it at some later moment -no promise, though, and in any case it can't be before I implemented remote server logging, which I hope I will provide in September/October.
Excellent library! Is it possible to add another column called 'Elapsed' to the right of the 'Time' column that would display the time difference between when the current log event occurred and the previous log event occurred? This would be very helpful. Thanks!
I only have one suggestion.............it could be possible to add a level config to the AppenderBase class.....
that´s way we can log message at specific level according the appender
log4js-ext 2.0 is out
I have finished version 2.0 of log4js-ext!
The main new features in 2.0 are:
You can see the search & highlight feature in action in the image below.
- Remote logging support: now you can send logs to a remote web app, and get them logged against Log4js, Slf4j and Apache Commons Logging.
- Enhanced built-in log viewer with search & highlight capabilities.
For more info, click here.
You can get it at https://code.google.com/p/log4js-ext
Do you have a version for Sencha Touch?