Labs/JS Modules: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 11: Line 11:
To use it, create one or more appenders while initializing your add-on, and create loggers in the places where you have logging messages to emit.  Both loggers and appenders have minimum log levels to allow you to customize your logging output without changing any code.
To use it, create one or more appenders while initializing your add-on, and create loggers in the places where you have logging messages to emit.  Both loggers and appenders have minimum log levels to allow you to customize your logging output without changing any code.


The implementation is much less comprehensive than what you might see in the log4* projects at Apache, however.  For example, support for serializing the logging configuration or reading it in is non-existent.
The implementation is much less comprehensive than what you might see in the log4* projects at Apache, however.  For example, support for serializing the logging configuration or reading it in is non-existent.  Also, note that this module used to be an XPCOM component and that influenced some of the interface design (e.g., Service.newAppender()).  That will change in the future.


Get it here:
Get it here:
* [http://hg.mozilla.org/labs/weave/index.cgi/file/8e3d60172f32/modules/log4moz.js log4moz.js] - Adorned
* [http://hg.mozilla.org/labs/weave/index.cgi/file/8e3d60172f32/modules/log4moz.js log4moz.js] - Adorned
* [http://hg.mozilla.org/labs/weave/index.cgi/raw-file/8e3d60172f32/modules/log4moz.js log4moz.js] - Raw (right-click to save)
* [http://hg.mozilla.org/labs/weave/index.cgi/raw-file/8e3d60172f32/modules/log4moz.js log4moz.js] - Raw (right-click to save)

Revision as of 06:12, 8 April 2008

Back to Labs.

JavsScript Modules

Here you'll find a collection of modules which you can import into your extension. They are designed to be imported with Components.utils.import(). If you would like to contribute a new module, get in touch with us at #labs!

Logging

This is a partial implementation of the Log4* interfaces (for example, see log4j or log4net). The original implementation came from Michael Johnston, but it was heavily modified by Dan Mills to get it into Weave.

To use it, create one or more appenders while initializing your add-on, and create loggers in the places where you have logging messages to emit. Both loggers and appenders have minimum log levels to allow you to customize your logging output without changing any code.

The implementation is much less comprehensive than what you might see in the log4* projects at Apache, however. For example, support for serializing the logging configuration or reading it in is non-existent. Also, note that this module used to be an XPCOM component and that influenced some of the interface design (e.g., Service.newAppender()). That will change in the future.

Get it here: