tclpkg-gtrace.cc

Go to the documentation of this file.
00001 /** @file tcl/tclpkg-gtrace.cc tcl interface package for tracing and
00002     profiling facilities */
00003 ///////////////////////////////////////////////////////////////////////
00004 //
00005 // Copyright (c) 2002-2004 California Institute of Technology
00006 // Copyright (c) 2004-2007 University of Southern California
00007 // Rob Peters <rjpeters at usc dot edu>
00008 //
00009 // created: Mon Jan 21 12:52:51 2002
00010 // commit: $Id: tclpkg-gtrace.cc 11876 2009-10-22 15:53:06Z icore $
00011 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/tcl/tclpkg-gtrace.cc $
00012 //
00013 // --------------------------------------------------------------------
00014 //
00015 // This file is part of GroovX
00016 //   [http://ilab.usc.edu/rjpeters/groovx/]
00017 //
00018 // GroovX is free software; you can redistribute it and/or modify it
00019 // under the terms of the GNU General Public License as published by
00020 // the Free Software Foundation; either version 2 of the License, or
00021 // (at your option) any later version.
00022 //
00023 // GroovX is distributed in the hope that it will be useful, but
00024 // WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 // General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License
00029 // along with GroovX; if not, write to the Free Software Foundation,
00030 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00031 //
00032 ///////////////////////////////////////////////////////////////////////
00033 
00034 #ifndef GROOVX_TCL_TCLPKG_GTRACE_CC_UTC20050628161246_DEFINED
00035 #define GROOVX_TCL_TCLPKG_GTRACE_CC_UTC20050628161246_DEFINED
00036 
00037 #include "tcl/tclpkg-gtrace.h"
00038 
00039 #include "tcl/pkg.h"
00040 
00041 #include "rutz/error.h"
00042 #include "rutz/fstring.h"
00043 #include "rutz/sfmt.h"
00044 
00045 #include <sstream>
00046 
00047 #include "rutz/debug.h"
00048 GVX_DBG_REGISTER
00049 #include "rutz/trace.h"
00050 
00051 namespace
00052 {
00053   rutz::fstring profSummary()
00054   {
00055     std::ostringstream oss;
00056     rutz::prof::print_all_prof_data(oss);
00057     return rutz::fstring(oss.str().c_str());
00058   }
00059 
00060   void setOneLevel(int key, int level)
00061   {
00062     if (!rutz::debug::is_valid_key(key))
00063       throw rutz::error(rutz::sfmt("no such debug key '%d'", key),
00064                         SRC_POS);
00065 
00066     // else...
00067     rutz::debug::set_level_for_key(key, level);
00068   }
00069 
00070   void setOneLevelc(const char* fname, int level)
00071   {
00072     const int key = rutz::debug::lookup_key(fname);
00073     if (key == -1)
00074       throw rutz::error(rutz::sfmt("no debug key for file '%s'", fname),
00075                         SRC_POS);
00076 
00077     GVX_ASSERT(rutz::debug::is_valid_key(key));
00078 
00079     rutz::debug::set_level_for_key(key, level);
00080   }
00081 }
00082 
00083 extern "C"
00084 int Gtrace_Init(Tcl_Interp* interp)
00085 {
00086 GVX_TRACE("Gtrace_Init");
00087 
00088   GVX_PKG_CREATE(pkg, interp, "Gtrace", "4.$Revision: 11876 $");
00089   pkg->def("::gtrace", "on_off", &rutz::trace::set_global_trace, SRC_POS);
00090   pkg->def("::gtrace", "", &rutz::trace::get_global_trace, SRC_POS);
00091   pkg->def("maxDepth", "level", &rutz::trace::set_max_level, SRC_POS);
00092   pkg->def("maxDepth", "", &rutz::trace::get_max_level, SRC_POS);
00093   pkg->def("::dbglevelg", "global_level", &rutz::debug::set_global_level, SRC_POS);
00094   pkg->def("::dbglevel", "key level", &setOneLevel, SRC_POS);
00095   pkg->def("::dbglevelc", "filename level", &setOneLevelc, SRC_POS);
00096   pkg->def("::dbgkey", "filename", &rutz::debug::lookup_key, SRC_POS);
00097 
00098   GVX_PKG_RETURN(pkg);
00099 }
00100 
00101 extern "C"
00102 int Prof_Init(Tcl_Interp* interp)
00103 {
00104 GVX_TRACE("Prof_Init");
00105 
00106   GVX_PKG_CREATE(pkg, interp, "Prof", "4.$Revision: 11876 $");
00107   pkg->def("summary", "", &profSummary, SRC_POS);
00108   pkg->def("reset", "", &rutz::prof::reset_all_prof_data, SRC_POS);
00109 
00110   GVX_PKG_RETURN(pkg);
00111 }
00112 
00113 static const char __attribute__((used)) vcid_groovx_tcl_tclpkg_gtrace_cc_utc20050628161246[] = "$Id: tclpkg-gtrace.cc 11876 2009-10-22 15:53:06Z icore $ $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/tcl/tclpkg-gtrace.cc $";
00114 #endif // !GROOVX_TCL_TCLPKG_GTRACE_CC_UTC20050628161246_DEFINED
Generated on Sun May 8 08:42:22 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3