|
Logging
GWT logging API.
Type-Library An updated logging system that emulates java.util.logging is now present in mainline GWT development. The incubator code has been deprecated. Current documentation is located in the main GWT project.
Design GoalsLogging API
Logging Handler/Appender/Publishing API
Design DecisionsDeferred bindingThe Logging api has three compiled options(logging:enabled/disabled/production). The other option would be to have a set of predefined levels i.e. logging(off/fine/finer/.../severe). Both are good options, so far we believe the single switch will lead to best full experience. Advantages for multiple levels:
Advantages of compiler all/none/minimal switch
Allowing direct access to Logger instancesIn some cases, it would be useful to directly access a Logger or Handler and print to that one alone. However, this code would probably not be compiled out in production, so this feature is currently not supported, though the design is meant to accommodation instance loggers. Design overviewLogLog is a static class. Its API is modeled on the java Logger API. Almost all user interactions should be done through this class to allow compile time removal of logging. It will also include some GWT-specific method. For instance the methods below: Log.isLoggingEnabled();
Log.isLoggingProduction();
Log.debug("I am a message");
LogHandlerA LogHandler is an interface which actually handles the logging messages. It is a gwt event handler with a single method LogHandler.onLog(LogEvent event) LogEventA LogEvent is created once the Log class determines that it should broadcast its messages to the registered LogHandler instances. LogFormatterAs log handlers are no longer classes, the formatting helper methods have been abstracted out into the LogFormatter hierarchy. We provide a default text and html log formatter. LevelDefines the current logging Level. Based on the java logging Level class. CategoriesCategories are represented by strings rather then a Category class. This was done because strings are optimized away more often then class objects. Categories are hierarchical using the "." notation. For instance, the following snippet of code uses categories to selectively log messages. Log.setDefaultLevel(Level.SEVERE);
Log.setLevel("gwt", Level.INFO);
Log.setLevel("gwt.logging", Level.FINE);
// This message will be logged.
Log.info("will log", "gwt.subsystem");
// This message will not be logged.
Log.fine("will not log", "gwt.subsystem");
// This message will log.
Log.fine("will log", "gwt.logging");
Logging statesEnabled
Production
DisabledNo logging support | ||||||||||
Under logging states it would be useful to add instructions on how to change the logging state at compile time in the .gwt.xml file.
The demo does seem to work for firefox.
Demo still doesn't work under FireFox? - is anyone working on this tool?