00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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
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: 10065 $");
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: 10065 $");
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 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00114 #endif // !GROOVX_TCL_TCLPKG_GTRACE_CC_UTC20050628161246_DEFINED