示例#1
0
文件: main.go 项目: huin/artemis
func main() {
	flag.Parse()
	if *streamFilename == "" {
		log.Fatal("--stream-file is a required argument.")
	}

	var valueIDFn artprotodump.ValueIDFn
	if *valueIDFilename != "" {
		valueIDFile, err := os.Create(*valueIDFilename)
		if err != nil {
			log.Fatal(err)
		}
		defer valueIDFile.Close()
		valueIDFn = func(valueID string, value interface{}) {
			fmt.Fprintf(valueIDFile, "%s\t%T\t%v\n", valueID, value, value)
		}
	}

	l := log.New(os.Stdout, "", 0)
	log.SetOutput(os.Stdout)

	f, err := os.Open(*streamFilename)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	if *streamIsClient {
		// Debug client stream.
		err = artprotodump.DumpClientEvents(f, l, 1024)
	} else {
		// Debug server stream.
		err = artprotodump.DumpServerEvents(f, valueIDFn, l, 1024)
	}
	if err == io.EOF {
		l.Printf("end of stream")
	} else {
		l.Printf("error reading frame: %v", err)
	}
}
示例#2
0
func readClientConn(r io.Reader, logger *log.Logger) {
	err := artprotodump.DumpClientEvents(r, logger, 1024)
	logger.Print("Error in dumping client data:", err)
}