CVS: jfor/src/org/jfor/jfor/main JForLogConfig.java,1.1,1.2
Bertrand Delacretaz <[email protected]> Tue, 24 Sep 2002 04:12:45 -0700
| Newsgroups | gmane.text.xml.jfor.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jfor/jfor/src/org/jfor/jfor/main
In directory usw-pr-cvs1:/tmp/cvs-serv2136/src/org/jfor/jfor/main
Modified Files:
JForLogConfig.java
Log Message:
Wrong version of JForLogConfig.java was checked in
Index: JForLogConfig.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/main/JForLogConfig.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** JForLogConfig.java 24 Sep 2002 10:13:17 -0000 1.1
--- JForLogConfig.java 24 Sep 2002 11:12:43 -0000 1.2
***************
*** 69,72 ****
--- 69,75 ----
// $Id$
// $Log$
+ // Revision 1.2 2002/09/24 11:12:43 bdelacretaz
+ // Wrong version of JForLogConfig.java was checked in
+ //
// Revision 1.1 2002/09/24 10:13:17 bdelacretaz
// V0.7.2dev-e - uses Apache logkit for more precise and configurable logging
***************
*** 84,95 ****
private static final String PROP_PREFIX = "log.priority.";
! /** default priorities for some log categories */
! private static final Map m_defPrio = new TreeMap();
! static {
! m_defPrio.put("jfor",Priority.INFO),
! m_defPrio.put("jfor.converter.sax.events",Priority.WARN);
! m_defPrio.put("jfor.converter.builder.actions",Priority.WARN);
}
/** Must be called before using any log4j Logger
* By default, configures log4j to use System.err for logging.
--- 87,104 ----
private static final String PROP_PREFIX = "log.priority.";
! /** used to define default priorities */
! private static class DefPrio {
! private final String name;
! private final Priority p;
! DefPrio(String theName,Priority theP) { name=aName; p=theP; }
}
+ /** default priorities for some log categories, must be ordered from less to more specific categories */
+ private static final DefPrio[] m_defPrio = new DefPrio[] {
+ new DefPrio("jfor",Priority.INFO),
+ new DefPrio("jfor.converter.sax.events",Priority.WARN),
+ new DefPrio("jfor.converter.builder.actions",Priority.WARN)
+ };
+
/** Must be called before using any log4j Logger
* By default, configures log4j to use System.err for logging.
***************
*** 102,122 ****
if(!runningUnderCocoon()) {
defaultToConsole();
! configureCategories();
}
m_configured = true;
}
}
!
! /** configure the priorities of relevant log categories */
! private static void configureCategories()
{
! for(Iterator it = m_defPrio.entrySet().iterator(); it.hasNext(); ) {
final Map.Entry e = (Map.Entry)it.next();
! final String name = (String)e.getKey();
! final Priority p = getPriorityForCategory(name,(Priority)e.getValue());
!
! Hierarchy.getDefaultHierarchy().getLoggerFor(name).setPriority(p);
if(m_logger.isInfoEnabled()) {
! m_logger.info("Priority of log category '" + name + "' set to '" + p + "'");
}
}
--- 111,152 ----
if(!runningUnderCocoon()) {
defaultToConsole();
! if(!configureFromSystemProperties()) {
! configureFromDefaults();
! }
}
m_configured = true;
}
}
!
! /** configure the priorities of relevant log categories from system properties
! * @return true if at least one category was configured
! */
! private static boolean configureFromSystemProperties()
{
! boolean result = false;
!
! for(Iterator = System.getProperties().entrySet(); it.hasNext(); ) {
final Map.Entry e = (Map.Entry)it.next();
! final String propName = (String)e.getKey();
! if(propName.startsWith(PROP_PREFIX)) {
! final String propValue = ((String)e.getValue()).toUpperCase();
! final String catName = propName.substring(PROP_PREFIX.length());
! final Priority p = Priority.getPriorityForName(propValue);
! Hierarchy.getDefaultHierarchy().getLoggerFor(catName).setPriority(p);
! if(m_logger.isInfoEnabled()) {
! m_logger.info("Using configured log priorities: category '" + catName + "' set to '" + p + "'");
! }
! }
! }
! return result;
! }
!
! /** configure the priorities of relevant log categories from our defaults */
! private static void configureFromDefaults()
! {
! for(int i=0; i < m_defPrio.length; i++) {
! Hierarchy.getDefaultHierarchy().getLoggerFor(m_defPrio[i].name).setPriority(m_defPrio[i].p);
if(m_logger.isInfoEnabled()) {
! m_logger.info("Using default log priorities: category '" + m_defPrio[i].name + "' set to '" + m_defPrio[i].p + "'");
}
}
***************
*** 124,129 ****
m_logger.info(
"System properties can be used to set log priorities, "
! + "using '-Dlog.priority.jfor.converter.builder.actions=debug', for example "
! + "would activate the DEBUG level of the jfor.converter.builder.actions category"
);
}
--- 154,159 ----
m_logger.info(
"System properties can be used to set log priorities, "
! + "using '-Dlog.priority.jfor=DEBUG', for example "
! + "would activate the DEBUG level for all categories under 'jfor'"
);
}
***************
*** 149,153 ****
* Logger.getLogTargets is deprecated, and I don't see another way to find out
*/
! private boolean runningUnderCocoon()
{
// try to load a class from Cocoon - if ok assume we're running under Cocoon
--- 179,183 ----
* Logger.getLogTargets is deprecated, and I don't see another way to find out
*/
! private static boolean runningUnderCocoon()
{
// try to load a class from Cocoon - if ok assume we're running under Cocoon
***************
*** 156,160 ****
boolean result = false;
try {
! class.forName(testClass);
result = true;
} catch(Exception ignoreThisException) {}
--- 186,190 ----
boolean result = false;
try {
! Class.forName(testClass);
result = true;
} catch(Exception ignoreThisException) {}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf