1.有时,我们想看到对于同一个url请求多次,输出的调试信息的变化。 2.或者当你调试的脚本需要重定向到其他脚本,然后又重定向回来,你希望能看到这些脚本的调试输出信息。 3.当你的脚本通过curl请求一个自己设计的api时,你想输出这个api的一些调试信息。 那
1.有时,我们想看到对于同一个url请求多次,输出的调试信息的变化。
2.或者当你调试的脚本需要重定向到其他脚本,然后又重定向回来,你希望能看到这些脚本的调试输出信息。
3.当你的脚本通过curl请求一个自己设计的api时,你想输出这个api的一些调试信息。
那么这个代理程序将能够帮到你,但它现在只能简单的输出一些调试信息,它仍需要完善。
详细介绍:https://github.com/yangxikun/proxy-debug/blob/master/readme_zh-cn.md
目前仅支持linux,因为使用到了shell的字符颜色功能 源码与演示:源码出处
$type, type=>gettype($arg), name=>self::getvarname(), value=>$arg ); } else { self::$debugitemcount++; header( 'proxy_debug_item_'.self::$debugitemcount.': ' .json_encode( [category=>$type, type=>gettype($arg), name=>self::getvarname(), value=>$arg] ) ); header('proxy_debug_item_count: '.self::$debugitemcount); } } public static function __callstatic($name, $args) { $func = ['info'=>'i', 'warn'=>'w', 'error'=>'e']; if (isset($func[$name])) { self::$offset = 0; self::$varnamestring = null; foreach ($args as $key => $arg) { self::func($func[$name], $arg); } } else { throw new exception('call to undefined method!', 1); } } /** * groupstart * start record a group * * @access public * @static * * @return null */ public static function groupstart() { self::$start = true; self::$debuggroupcount++; } /** * groupend * stop record a group * * @access public * @static * * @return null */ public static function groupend() { self::$start = false; header( 'proxy_debug_group_' .self::$debuggroupcount .': '.json_encode(self::$group) ); header('proxy_debug_group_count: '.self::$debuggroupcount); self::$group = array(); }}
//proxy debug//this simple program is for helping developers debug through http header.//for more detail, see readme.mdpackage mainimport ( bufio encoding/json fmt io/ioutil log net/http os strconv strings)//color configvar color map[string]interface{}//parse config filefunc readconfig() { config, err := os.open(config.ini) if err != nil { log.fatalln(err) } buf := bufio.newreader(config) line, _ := buf.readstring('\n') var jsondata interface{} err = json.unmarshal([]byte(line), &jsondata) if err != nil { log.fatalln(err) } var ok bool color, ok = jsondata.(map[string]interface{}) if ok == false { log.fatalln(parse config file error, it must be a json string!) } for _, c := range color { if c.(float64) > 37 || c.(float64) 65535 || port maxlenname[k] { maxlenname[k] = len(v) } v = vk[type].(string) if len(v) > maxlentype[k] { maxlentype[k] = len(v) } } k++ } k = 0 for _, i := range debuggroupindex { fmt.printf(\t\033[%vm=group %v=\n, color[group], k+1) for _, v := range debuggroup[i].([]interface{}) { vk, ok := v.(map[string]interface{}) if ok == false { continue } n := vk[name].(string) t := vk[type].(string) c := vk[category].(string) fmt.printf( format, caterory[c], c, color[varname], n+strings.repeat( , maxlenname[k]-len(n)+1), color[vartype], t+strings.repeat( , maxlentype[k]-len(t)+1), color[varvalue], strings.replace(fmt.sprint(vk[value]), map, , 1)) } k++ fmt.printf(\t\033[%vm=group=\n, color[group]) } } }) http.listenandserve(:+strconv.itoa(port), nil)}