summaryrefslogtreecommitdiff
path: root/src/de/lmu/ifi/dbs/elki/logging/Logging.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/logging/Logging.java')
-rw-r--r--src/de/lmu/ifi/dbs/elki/logging/Logging.java82
1 files changed, 80 insertions, 2 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/logging/Logging.java b/src/de/lmu/ifi/dbs/elki/logging/Logging.java
index b9cbc16d..99b6152b 100644
--- a/src/de/lmu/ifi/dbs/elki/logging/Logging.java
+++ b/src/de/lmu/ifi/dbs/elki/logging/Logging.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.logging;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2013
+ Copyright (C) 2014
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -27,8 +27,12 @@ import java.util.HashMap;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
+import de.lmu.ifi.dbs.elki.logging.progress.AbstractProgress;
+import de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress;
+import de.lmu.ifi.dbs.elki.logging.progress.IndefiniteProgress;
import de.lmu.ifi.dbs.elki.logging.progress.Progress;
import de.lmu.ifi.dbs.elki.logging.progress.ProgressLogRecord;
+import de.lmu.ifi.dbs.elki.logging.progress.StepProgress;
import de.lmu.ifi.dbs.elki.logging.statistics.Counter;
import de.lmu.ifi.dbs.elki.logging.statistics.Duration;
import de.lmu.ifi.dbs.elki.logging.statistics.MillisTimeDuration;
@@ -111,6 +115,19 @@ public class Logging {
public Level(String name, int value) {
super(name, value);
}
+
+ /**
+ * Parse a logging level.
+ *
+ * @param levelName Name of level to parse.
+ * @return {@link java.util.logging.Level} level
+ */
+ public static java.util.logging.Level parse(String levelName) {
+ // While this is a pass-through to the parent class,
+ // it ensures our own level have been added.
+ // Otherwise, levels such as "STATISTICS" might not work!
+ return java.util.logging.Level.parse(levelName);
+ }
}
/**
@@ -140,7 +157,7 @@ public class Logging {
*/
public synchronized static Logging getLogger(final String name) {
Logging logger = loggers.get(name);
- if (logger == null) {
+ if(logger == null) {
logger = new Logging(Logger.getLogger(name));
loggers.put(name, logger);
}
@@ -607,6 +624,67 @@ public class Logging {
}
/**
+ * Increment a progress (unless {@code null}).
+ *
+ * @param prog Progress to increment, may be {@code null}.
+ */
+ public void incrementProcessed(AbstractProgress prog) {
+ if(prog != null) {
+ prog.incrementProcessed(this);
+ }
+ }
+
+ /**
+ * Increment a progress (unless {@code null}).
+ *
+ * @param prog Progress to complete, may be {@code null}.
+ */
+ public void ensureCompleted(FiniteProgress prog) {
+ if(prog != null) {
+ prog.ensureCompleted(this);
+ }
+ }
+
+ /**
+ * Begin a new algorithm step (unless {@code null}).
+ *
+ * <b>Important:</b> Do not use this method when the parameter are not static.
+ * In these cases, check whether logging is enabled first, to avoid computing
+ * method parameters!
+ *
+ * @param prog Progress to increment, may be {@code null}.
+ * @param step Step number
+ * @param title Step title
+ */
+ public void beginStep(StepProgress prog, int step, String title) {
+ if(prog != null) {
+ prog.beginStep(step, title, this);
+ }
+ }
+
+ /**
+ * Finish a progress (unless {@code null}).
+ *
+ * @param prog Progress to complete, may be {@code null}.
+ */
+ public void setCompleted(StepProgress prog) {
+ if(prog != null) {
+ prog.setCompleted(this);
+ }
+ }
+
+ /**
+ * Finish a progress (unless {@code null}).
+ *
+ * @param prog Progress to complete, may be {@code null}.
+ */
+ public void setCompleted(IndefiniteProgress prog) {
+ if(prog != null) {
+ prog.setCompleted(this);
+ }
+ }
+
+ /**
* Log a statistics object.
*
* @param stats Statistics object to report.