Hello all
A MonolineFormatter class has been commited to the CVS tree (module
"resources"). There is two way to enable this. One way is hard-coded,
the other way is to edit "jre/lib/logging.properties". First a few note:
1) MonolineFormatter produces output like the following:
[core FINE] There is a message with FINE level.
[core WARNING] There is a message with WARNING level.
Please tell me if you prefers other format ("FINE" before "core",
left align "FINE" instead of right alignment, etc.) I don't mind
for the format. By default, the [...] header use 15 spaces. Again,
tell me if you prefer an other amount.
2) MonolineFormatter apply *only* to "org.geotools" logger and its
children ("org.geotools.core", "org.geotools.gml", etc.). Other
loggers (e.g. "com.mycompagny") will still use the usual formatting,
according the user setup.
How to enable MonolineFormatting:
1) Hard-code it: just invoke the following somewhere in yours code:
GeotoolsHandler.init("org.geotools");
For example, you can invoke it from a main(String[]) method. You
can also invokes it in the static initializer of some class. The
drawback of hard-codding this logger initialization is that the
user will automatically have this formatting for all packages in
"org.geotools", even if for some raison he wanted the J2SE's
formatting.
2) No hard-code; instead, edit the "handlers=" line in the
"jre/lib/logging.properties". Example:
handlers= java.util.logging.ConsoleHandler,
org.geotools.resources.GeotoolsHandler
With this method, the user have our personal formatting only if
he want it. The inconvenient is that he have to edit the properties
file. A second inconvenient is that I'm havind a hard time to debug
this way (it work, except for the very first logged message. It also
conflict with way #1; we can have one or the other, but not both).
I'm still trying to debug it.
So we are faced to a choice:
-> Do we automatically register our personal logger for "org.geotools"
packages at Geotools's startup? Or do we lets user configure its
"logging.properties" file if he want?
Note that automatically registering our logger don't means that the
user will have log message if he don't want. Basically,
GeotoolsHandler just repace any ConsoleHandler occurences it found.
Its means that if there is no ConsoleHandler for "org.geotools"
packages (i.e. the user didn't want logging to the console), no
GeotoolsHandler will be registered.
If we choose automatic registering, then I suggest to create a class
"Geotools" somewhere with a static method "init()" that initialize
everything that may need to be initialized (our personal logger may not
be the only thing to initialize).
Martin.
|