added logging to WeightedRips (still needs debugging) dev
authorChristos Mantoulidis <cmad@stanford.edu>
Mon, 27 Jul 2009 21:42:51 -0700
branchdev
changeset 152 fdc2835b3e88
parent 151 104ea146b9bc
child 153 7731c42892de
added logging to WeightedRips (still needs debugging)
examples/rips/rips-weighted.cpp
include/topology/weighted-rips.h
include/topology/weighted-rips.hpp
--- a/examples/rips/rips-weighted.cpp	Mon Jul 13 19:44:04 2009 -0700
+++ b/examples/rips/rips-weighted.cpp	Mon Jul 27 21:42:51 2009 -0700
@@ -37,6 +37,12 @@
 
 int main(int argc, char* argv[])
 {
+#ifdef LOGGING
+    rlog::RLogInit(argc, argv);
+
+    stderrLog.subscribeTo( RLOG_CHANNEL("error") );
+#endif
+
     Dimension               skeleton;
     DistanceType            max_distance;
     std::string             infilename;
@@ -58,7 +64,7 @@
         it->data() = rips.distance(*it, *it);
 
     std::sort(complex.begin(), complex.end(), Smplx::VertexComparison());       // unnecessary
-    std::cout << "Generated complex of size: " << complex.size() << std::endl;
+    std::cout << "# Generated complex of size: " << complex.size() << std::endl;
 
     // Generate filtration with respect to distance and compute its persistence
     Fltr f(complex.begin(), complex.end(), DataDimensionComparison<Smplx>());
@@ -92,7 +98,7 @@
         }
     }
     
-    persistence_timer.check("Persistence timer");
+    persistence_timer.check("# Persistence timer");
 }
 
 void        program_options(int argc, char* argv[], std::string& infilename, Dimension& skeleton, DistanceType& max_distance)
@@ -108,6 +114,11 @@
         ("help,h",                                                                                  "produce help message")
         ("skeleton-dimsnion,s", po::value<Dimension>(&skeleton)->default_value(2),                  "Dimension of the weighted Rips complex we want to compute")
         ("max-distance,m",      po::value<DistanceType>(&max_distance)->default_value(Infinity),    "Maximum value for the weighted Rips complex construction");
+#if LOGGING
+    std::vector<std::string>    log_channels;
+    visible.add_options()
+        ("log,l",               po::value< std::vector<std::string> >(&log_channels),           "log channels to turn on (info, debug, etc)");
+#endif
 
     po::positional_options_description pos;
     pos.add("input-file", 1);
@@ -119,6 +130,15 @@
                   options(all).positional(pos).run(), vm);
     po::notify(vm);
 
+#if LOGGING
+    for (std::vector<std::string>::const_iterator cur = log_channels.begin(); cur != log_channels.end(); ++cur)
+        stderrLog.subscribeTo( RLOG_CHANNEL(cur->c_str()) );
+    /**
+     * Interesting channels
+     * "info", "debug", "topology/persistence"
+     */
+#endif
+
     if (vm.count("help") || !vm.count("input-file"))
     { 
         std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl;
--- a/include/topology/weighted-rips.h	Mon Jul 13 19:44:04 2009 -0700
+++ b/include/topology/weighted-rips.h	Mon Jul 27 21:42:51 2009 -0700
@@ -7,7 +7,6 @@
 #include "rips.h"
 #include <boost/iterator/counting_iterator.hpp>
 
-
 /**
  * WeightedRips class
  *
--- a/include/topology/weighted-rips.hpp	Mon Jul 13 19:44:04 2009 -0700
+++ b/include/topology/weighted-rips.hpp	Mon Jul 27 21:42:51 2009 -0700
@@ -9,10 +9,10 @@
 #include <functional>
 
 #ifdef LOGGING
-static rlog::RLogChannel* rlRips =                  DEF_CHANNEL("rips/info", rlog::Log_Debug);  /* TODO: change rips/ to weighted-rips/ ? */
-static rlog::RLogChannel* rlRipsDebug =             DEF_CHANNEL("rips/debug", rlog::Log_Debug); /* TODO: same here */
+static rlog::RLogChannel* rlWeightedRips =                  DEF_CHANNEL("weightedrips/info", rlog::Log_Debug);
+static rlog::RLogChannel* rlWeightedRipsDebug =             DEF_CHANNEL("weightedrips/debug", rlog::Log_Debug);
 #endif // LOGGING
 
 #ifdef COUNTERS
-static Counter*  cClique =                          GetCounter("rips/clique");                  /* TODO: same here */
+static Counter*  cClique =                          GetCounter("weightedrips/clique");
 #endif // COUNTERS