Logger
Last updated
Last updated
Elemento contains a small wrapper around console.log
that uses categories, log levels, and a predefined log format.
The different log methods delegate to the corresponding methods in console
:
Logger.error(String, Object... params)
→
Logger.warn(String, Object... params)
→
Logger.info(String, Object... params)
→
Logger.debug(String, Object... params)
→
To get a logger, use Logger.getLogger(String category)
.
You can use an arbitrary string as a category. By using a hierarchical category, you can override subcategories. are supported, and you can pass a variable list of parameters to the log methods.
The log level is set globally for all categories using Logger.setLevel(Level level)
. You can override the level for one category using Logger.setLevel(String category, Level level)
. To reset a category, use Logger.resetLevel(String category)
. If the category contains .
, it is interpreted hierarchically. This means that if the category org.jboss
is overridden, this is also applied to all subcategories (unless overridden otherwise).
The log format is predefined as
and cannot be customized. The package names are shortened if the category is a fully qualified class name. In any case, the category is trimmed and right-aligned.
The logger module exports some methods with slightly adjusted signatures to JavaScript. You can use them, for instance, in the browser dev tools to control the global and category-based log levels:
org.jboss.elemento.logger.Logger.setLevel(String level)
Sets the global log level
org.jboss.elemento.logger.Logger.setLevel(String category, String level)
Overrides the log level for one category
org.jboss.elemento.logger.Logger.resetLevel(String category)
Resets the log level for the category to the global log level
Please use the fully qualified name!
Add the following dependency to use elemento-logger
:
In your GWT module, inherit from org.jboss.elemento.Logger
: