summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/Logging.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/gluegen/Logging.java')
-rw-r--r--src/java/com/jogamp/gluegen/Logging.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/java/com/jogamp/gluegen/Logging.java b/src/java/com/jogamp/gluegen/Logging.java
index 40eadcb..77856f4 100644
--- a/src/java/com/jogamp/gluegen/Logging.java
+++ b/src/java/com/jogamp/gluegen/Logging.java
@@ -33,6 +33,7 @@ package com.jogamp.gluegen;
import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
+import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
@@ -41,11 +42,13 @@ import com.jogamp.common.util.PropertyAccess;
/**
*
- * @author Michael Bien
+ * @author Michael Bien, et.al.
*/
public class Logging {
- static void init() {
+ final static Logger rootPackageLogger;
+
+ static {
final String packageName = Logging.class.getPackage().getName();
final String property = PropertyAccess.getProperty(packageName+".level", true);
Level level;
@@ -64,12 +67,35 @@ public class Logging {
handler.setFormatter(new PlainLogFormatter());
handler.setLevel(level);
- final Logger rootPackageLogger = Logger.getLogger(packageName);
+ rootPackageLogger = Logger.getLogger(packageName);
rootPackageLogger.setUseParentHandlers(false);
rootPackageLogger.setLevel(level);
rootPackageLogger.addHandler(handler);
}
+ /** provokes static initialization */
+ static void init() { }
+
+ /** Returns the <i>root package logger</i>. */
+ public static Logger getLogger() {
+ return rootPackageLogger;
+ }
+ /** Returns the demanded logger, while aligning its log-level to the root logger's level. */
+ public static synchronized Logger getLogger(final String name) {
+ final Logger l = Logger.getLogger(name);
+ alignLevel(l);
+ return l;
+ }
+ /** Align log-level of given logger to the root logger's level. */
+ public static void alignLevel(final Logger l) {
+ final Level level = rootPackageLogger.getLevel();
+ l.setLevel(level);
+ final Handler[] hs = l.getHandlers();
+ for(final Handler h:hs) {
+ h.setLevel(level);
+ }
+ }
+
/**
* This log formatter needs usually one line per log record.
* @author Michael Bien