Golang SetFlags示例

说明

golang setflags示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Golang

命名空间/包名称: log

示例#1
文件: mysql-sniffer.go 项目: jayed/mysql-sniffer

func handleStatusUpdate(displaycount int) {
	elapsed := float64(UnixNow() - start)

	// print status bar
	log.Printf("\n")
	log.SetFlags(log.Ldate | log.Ltime)
	log.Printf("%d total queries, %0.2f per second", querycount, float64(querycount)/elapsed)
	log.SetFlags(0)

	// we cheat so badly here...
	var tmp sort.StringSlice = make([]string, 0, len(qbuf))
	for q, c := range qbuf {
		tmp = append(tmp, fmt.Sprintf("%6d  %0.2f/s  %s", c, float64(c)/elapsed, q))
	}
	sort.Sort(tmp)

	// now print top to bottom, since our sorted list is sorted backwards
	// from what we want
	if len(tmp) < displaycount {
		displaycount = len(tmp)
	}
	for i := 1; i <= displaycount; i++ {
		log.Printf(tmp[len(tmp)-i])
	}
}

示例#2
文件: nats-rply.go 项目: aminjam/mq-resource

func main() {
	var urls = flag.String("s", nats.DefaultURL, "The nats server URLs (separated by comma)")
	var showTime = flag.Bool("t", false, "Display timestamps")

	log.SetFlags(0)
	flag.Usage = usage
	flag.Parse()

	args := flag.Args()
	if len(args) < 2 {
		usage()
	}

	nc, err := nats.Connect(*urls)
	if err != nil {
		log.Fatalf("Can't connect: %v\n", err)
	}

	subj, reply, i := args[0], args[1], 0

	nc.Subscribe(subj, func(msg *nats.Msg) {
		i++
		printMsg(msg, i)
		nc.Publish(msg.Reply, []byte(reply))
	})

	log.Printf("Listening on [%s]\n", subj)
	if *showTime {
		log.SetFlags(log.LstdFlags)
	}

	runtime.Goexit()
}

示例#3
文件: mysql-sniffer.go 项目: zorkian/mysql-sniffer

func handleStatusUpdate(displaycount int, sortby string, cutoff int) {
	elapsed := float64(UnixNow() - start)

	// print status bar
	log.Printf("\n")
	log.SetFlags(log.Ldate | log.Ltime)
	log.Printf("%s%d total queries, %0.2f per second%s", COLOR_RED, querycount,
		float64(querycount)/elapsed, COLOR_DEFAULT)
	log.SetFlags(0)

	log.Printf("%d packets (%0.2f%% on synchronized streams) / %d desyncs / %d streams",
		stats.packets.rcvd, float64(stats.packets.rcvd_sync)/float64(stats.packets.rcvd)*100,
		stats.desyncs, stats.streams)

	// global timing values
	gmin, gavg, gmax := calculateTimes(×)
	log.Printf("%0.2fms min / %0.2fms avg / %0.2fms max query times", gmin, gavg, gmax)
	log.Printf("%d unique results in this filter", len(qbuf))
	log.Printf(" ")
	log.Printf("%s count     %sqps     %s  min    avg   max      %sbytes      per qry%s",
		COLOR_YELLOW, COLOR_CYAN, COLOR_YELLOW, COLOR_GREEN, COLOR_DEFAULT)

	// we cheat so badly here...
	var tmp sortableSlice = make(sortableSlice, 0, len(qbuf))
	for q, c := range qbuf {
		qps := float64(c.count) / elapsed
		if qps < float64(cutoff) {
			continue
		}

		qmin, qavg, qmax := calculateTimes(&c.times)
		bavg := uint64(float64(c.bytes) / float64(c.count))

		sorted := float64(c.count)
		if sortby == "avg" {
			sorted = qavg
		} else if sortby == "max" {
			sorted = qmax
		} else if sortby == "maxbytes" {
			sorted = float64(c.bytes)
		} else if sortby == "avgbytes" {
			sorted = float64(bavg)
		}

		tmp = append(tmp, sortable{sorted, fmt.Sprintf(
			"%s%6d  %s%7.2f/s  %s%6.2f %6.2f %6.2f  %s%9db %6db %s%s%s",
			COLOR_YELLOW, c.count, COLOR_CYAN, qps, COLOR_YELLOW, qmin, qavg, qmax,
			COLOR_GREEN, c.bytes, bavg, COLOR_WHITE, q, COLOR_DEFAULT)})
	}
	sort.Sort(tmp)

	// now print top to bottom, since our sorted list is sorted backwards
	// from what we want
	if len(tmp) < displaycount {
		displaycount = len(tmp)
	}
	for i := 1; i <= displaycount; i++ {
		log.Printf(tmp[len(tmp)-i].line)
	}
}

示例#4
文件: log.go 项目: ibmendoza/dgtk

func init() {
	if os.Getenv("DEBUG") == "true" {
		log.SetFlags(log.Llongfile)
	} else {
		log.SetFlags(0)
	}
}

示例#5
文件: main.go 项目: carriercomm/docker-hive

func main() {
	log.SetFlags(0)
	flag.Parse()
	if version {
		fmt.Println(VERSION)
		os.Exit(0)
	}

	rand.Seed(time.Now().UnixNano())
	log.SetFlags(log.LstdFlags)
	log.Printf("Docker Hive %s\n", VERSION)

	// connect to redis
	pool := utils.NewRedisPool(redisHost, redisPort, redisPass)
	// set node name
	if nodeName == "" {
		name, err := os.Hostname()
		if err != nil {
			log.Printf("Error getting hostname: %s", err)
			nodeName = "localhost"
		}
		nodeName = name
	}
	// start node
	engine := hive.NewEngine(host, port, dockerPath, VERSION, nodeName, zone, pool, runPolicy)

	waiter, err := engine.Start()
	if err != nil {
		log.Fatal(err)
		return
	}
	waiter.Wait()
}

示例#6
文件: edgar_receive.go 项目: jduhamel/edgar-sample

func main() {
	var urls = flag.String("nats", nats.DefaultURL, "The nats server URLs (separated by comma)")
	var mgoDB = flag.String("db", "localhost:27017", "Mongo databast URL")
	var showTime = flag.Bool("t", false, "Display timestamps")

	log.SetFlags(0)
	flag.Usage = usage
	flag.Parse()

	args := flag.Args()
	if len(args) < 1 {
		usage()
		fmt.Println("mgoDB", mgoDB)
	}

	opts := nats.DefaultOptions
	opts.Servers = strings.Split(*urls, ",")
	for i, s := range opts.Servers {
		opts.Servers[i] = strings.Trim(s, " ")
	}

	nc, err := opts.Connect()
	if err != nil {
		log.Fatalf("Can't connect: %v\n", err)
	}

	subj, i := args[0], 0

	nc.Subscribe(subj, func(msg *nats.Msg) {
		// ok we need to write this to a mgo database and assume that it's mostly valid ;)
		// we will use the last part of the subj as the collection and the first part as the db.
		// First we convert the Msg into a json obj.
		// then we dump the json into Bson and into mongo.

		var jsonObj map[string]interface{}

		err := json.Unmarshal([]byte(msg.Data), &jsonObj)
		if err != nil {
			// Bad json.
			log.Fatalf("Bad json passed: (%s)\n", msg.Data)
		}

		// ok let's split the msg subject and use part 1 for db and part 2 for collection. throwing away the rest
		foo := strings.Split(subj, ".")

		// Create mgo session
		session, err := mgo.Dial(*mgoDB)
		c := session.Copy().DB(foo[0]).C(foo[1]) // Add the mongo db stuff
		c.Insert(jsonObj)

		printMsg(msg, i)
	})

	log.Printf("Listening on [%s]\n", subj)
	if *showTime {
		log.SetFlags(log.LstdFlags)
	}

	runtime.Goexit()
}

示例#7
文件: main.go 项目: jmptrader/copy-bench

func main() {
	log.SetFlags(0)
	flag.Parse()
	path := flag.Arg(0)
	if path == "" {
		log.Fatal("usage: copy-bench PATH")
	}

	log.SetFlags(log.LstdFlags | log.Lmicroseconds)
	runtime.GOMAXPROCS(2)

	// Check if this is a new data file.
	_, err := os.Stat(path)
	isNew := os.IsNotExist(err)

	// Open database.
	db, err := bolt.Open(path, 0600)
	if err != nil {
		log.Fatal(err)
	}

	// Populate the initial database.
	if isNew {
		if err := seed(db); err != nil {
			log.Fatal(err)
		}
	}

	// Print stats of the db.
	if err := stat(db); err != nil {
		log.Fatal(err)
	}

	// Iterate once to push pages into memory.
	c := make(chan bool)
	fmt.Println("first run (ignore)")
	go func() { iterate(db, c) }()
	c <- true
	fmt.Println("")

	// Time iteration without copy.
	fmt.Println("iterate only")
	go iterate(db, c)
	time.Sleep(2 * time.Second)
	c <- true
	fmt.Println("")

	// Start iterator thread.
	fmt.Println("iterate during copy")
	go iterate(db, c)

	// Begin copy of the database.
	if err := dbcopy(db); err != nil {
		log.Fatal(err)
	}

	// Notify iterator of db copy completion.
	c <- true
	time.Sleep(100 * time.Millisecond)
}

示例#8
文件: main.go 项目: schollz/boltd

func main() {
	log.SetFlags(0)
	var (
		addr = flag.String("addr", ":9000", "bind address")
	)
	flag.Parse()

	// Validate parameters.
	var path = flag.Arg(0)
	if path == "" {
		log.Fatal("path required")
	}

	// Open the database.
	db, err := bolt.Open(path, 0600, nil)
	if err != nil {
		log.Fatal(err)
	}

	// Enable logging.
	log.SetFlags(log.LstdFlags)

	// Setup the HTTP handlers.
	http.Handle("/", boltd.NewHandler(db))

	// Start the HTTP server.
	go func() { log.Fatal(http.ListenAndServe(*addr, nil)) }()

	fmt.Printf("Listening on http://localhost%s\n", *addr)
	select {}
}

示例#9
文件: main.go 项目: raff/raftd

func main() {
	log.SetFlags(0)
	flag.Parse()
	if verbose {
		log.Print("Verbose logging enabled.")
	}
	if trace {
		raft.SetLogLevel(raft.Trace)
		log.Print("Raft trace debugging enabled.")
	} else if debug {
		raft.SetLogLevel(raft.Debug)
		log.Print("Raft debugging enabled.")
	}

	rand.Seed(time.Now().UnixNano())

	// Setup commands.
	raft.RegisterCommand(&command.WriteCommand{})

	// Set the data directory.
	if flag.NArg() == 0 {
		log.Fatal("Data path argument required")
	}
	path := flag.Arg(0)
	if err := os.MkdirAll(path, 0744); err != nil {
		log.Fatalf("Unable to create path: %v", err)
	}

	log.SetFlags(log.LstdFlags)
	s := server.New(path, host, port)
	log.Fatal(s.ListenAndServe(join))
}

示例#10
文件: logging.go 项目: strukturag/phoenix

func setSystemLogger(name string, w io.Writer) {
	log.SetOutput(w)
	if name != "" {
		log.SetPrefix(name + " ")
		log.SetFlags(log.LstdFlags)
	} else {
		log.SetFlags(log.LstdFlags &^ (log.Ldate | log.Ltime))
	}
}

示例#11
文件: errors.go 项目: dmexe/log-shuttle

func WarnErr(err error, msg ...interface{}) error {
	if err != nil {
		f := log.Flags()
		log.SetFlags(0)
		log.Println(makeErr(err, msg...))
		log.SetFlags(f)
	}
	return err
}

示例#12
文件: log.go 项目: sknop/direnv

func logMsg(format, msg string, a ...interface{}) {
	defer log.SetFlags(log.Flags())
	defer log.SetPrefix(log.Prefix())
	log.SetFlags(0)
	log.SetPrefix("")

	msg = fmt.Sprintf(format+"\n", msg)
	log.Printf(msg, a...)
}

示例#13
文件: log.go 项目: sknop/direnv

func setupLogging(env Env) {
	log.SetFlags(0)
	log.SetPrefix("")
	if val, ok := env[DIRENV_DEBUG]; ok == true && val == "1" {
		debugging = true
		log.SetFlags(log.Ltime)
		log.SetPrefix("direnv: ")
	}
}

示例#14
文件: log.go 项目: sknop/direnv

func log_debug(msg string, a ...interface{}) {
	if !debugging {
		return
	}
	defer log.SetFlags(log.Flags())
	log.SetFlags(log.Flags() | log.Lshortfile)
	msg = fmt.Sprintf(msg, a...)
	log.Output(2, msg)
}

示例#15
文件: debug.go 项目: Anaminus/rbxplore

func InitDebug() {
	if Option.Debug {
		log.SetFlags(log.Ltime)
		log.SetOutput(os.Stdout)
	} else {
		log.SetFlags(0)
		log.SetOutput(ioutil.Discard)
	}
}

示例#16
文件: otr_event_handler_test.go 项目: grayleonard/coyim

func captureLog(f func()) string {
	buf := new(bytes.Buffer)
	prevFlags := log.Flags()
	log.SetFlags(0)
	log.SetOutput(buf)
	f()
	log.SetFlags(prevFlags)
	log.SetOutput(ioutil.Discard)
	return buf.String()
}

示例#17
文件: logger.go 项目: TimothyYe/godns

//flush buf data to std log
func (this *Logger) Flush() {
	if this.buf.Len() > 0 {
		this.mu.Lock()
		defer this.mu.Unlock()

		log.SetFlags(0)
		log.Print(this.buf)
		log.SetFlags(log.LstdFlags)
		this.buf.Reset()
	}
}

示例#18
文件: logging.go 项目: couchbaselabs/cbgb

func initLogger(slog bool) {
	if slog {
		lw, err := syslog.New(syslog.LOG_INFO, "cbgb")
		must(err)
		log.SetOutput(lw)
		log.SetFlags(0)
	}
	if *logPlain {
		log.SetFlags(0)
	}
}

示例#19
文件: main.go 项目: kimitoboku/RecResolve

func main() {
	app := cli.NewApp()
	app.Usage = "It is a tool to see Iterative Search of the DNS is how to."
	app.Version = Version

	app.Commands = []cli.Command{
		{
			Name:    "rec",
			Aliases: []string{"r"},
			Usage:   "Iterative Search",
			Action: func(c *cli.Context) {
				if debug {
					log.SetFlags(log.Llongfile)
				}
				recRsolve(c.Args().First(), root, 0)
			},
		},
		{
			Name:    "norec",
			Aliases: []string{"n"},
			Usage:   "No Iterative Search",
			Action: func(c *cli.Context) {
				if debug {
					log.SetFlags(log.Llongfile)
				}
				noRecRsolve(c.Args().First(), root)
			},
		},
	}

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "root",
			Value:       "202.12.27.33",
			Usage:       "Root DNS Server's IP address",
			Destination: &root,
		},
		cli.BoolFlag{
			Name:        "debug",
			Usage:       "Debug Option for Developer",
			EnvVar:      "false",
			Destination: &debug,
		},
		cli.BoolFlag{
			Name:        "fool",
			Usage:       "Believe something like flue record",
			EnvVar:      "false",
			Destination: &fool,
		},
	}
	if err := app.Run(os.Args); err != nil {
		fmt.Println(err)
	}
}

示例#20
文件: main.go 项目: rayleyva/skybox

func main() {
	log.SetFlags(0)

	// Read configuration.
	flag.Usage = usage
	flag.Parse()

	// Validate arguments.
	if *dataDir == "" {
		log.Fatal("data directory required: --data-dir")
	} else if *certFile != "" && *keyFile == "" {
		log.Fatal("key file required: --key-file")
	} else if *keyFile != "" && *certFile == "" {
		log.Fatal("certificate file required: --cert-file")
	}
	var useTLS = (*certFile != "" && *keyFile != "")

	// Initialize data directory.
	if err := os.MkdirAll(*dataDir, 0700); err != nil {
		log.Fatal(err)
	}

	// Seed the PRNG for API key generation.
	rand.Seed(time.Now().Unix())

	// Initialize db.
	var db db.DB
	if err := db.Open(filepath.Join(*dataDir, "db"), 0666); err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	// Initialize handler.
	h, err := server.NewHandler(&db)
	if err != nil {
		log.Fatal(err)
	}
	logHandler := handlers.CombinedLoggingHandler(os.Stdout, h)

	// Start servers.
	log.Printf("Listening on http://localhost%s", *addr)
	if useTLS {
		log.Printf("Listening on http://localhost%s", *tlsAddr)
	}
	log.SetFlags(log.LstdFlags)

	go func() { log.Fatal(http.ListenAndServe(*addr, logHandler)) }()
	if useTLS {
		go func() { log.Fatal(http.ListenAndServeTLS(*tlsAddr, *certFile, *keyFile, logHandler)) }()
	}

	select {}
}

示例#21
文件: logging_test.go 项目: smartystreets/logging

func TestLoggingWithNilReferenceProducesTraditionalBehavior(t *testing.T) {
	out := new(bytes.Buffer)
	log.SetOutput(out)
	log.SetFlags(0)
	defer log.SetOutput(os.Stdout)
	defer log.SetFlags(log.LstdFlags)

	thing := new(ThingUnderTest)
	thing.Action()

	assertions.New(t).So(out.String(), should.Equal, "Hello, World!\n")
}

示例#22
文件: logging.go 项目: steveyen/cbgb

func initLogger(slog bool) {
	if slog {
		lw, err := syslog.New(syslog.LOG_INFO, "cbgb")
		if err != nil {
			log.Fatalf("Can't initialize syslog: %v", err)
		}
		log.SetOutput(lw)
		log.SetFlags(0)
	}
	if *logPlain {
		log.SetFlags(0)
	}
}

示例#23
文件: config.go 项目: shashikiranrp/caddy

// Load reads input (named filename) and parses it, returning server
// configurations grouped by listening address.
func Load(filename string, input io.Reader) (Group, error) {
	var configs []server.Config

	// turn off timestamp for parsing
	flags := log.Flags()
	log.SetFlags(0)

	serverBlocks, err := parse.ServerBlocks(filename, input)
	if err != nil {
		return nil, err
	}
	if len(serverBlocks) == 0 {
		return Default()
	}

	// Each server block represents one or more servers/addresses.
	// Iterate each server block and make a config for each one,
	// executing the directives that were parsed.
	for _, sb := range serverBlocks {
		sharedConfig, err := serverBlockToConfig(filename, sb)
		if err != nil {
			return nil, err
		}

		// Now share the config with as many hosts as share the server block
		for i, addr := range sb.Addresses {
			config := sharedConfig
			config.Host = addr.Host
			config.Port = addr.Port
			if config.Port == "" {
				config.Port = Port
			}
			if config.Port == "http" {
				config.TLS.Enabled = false
				log.Printf("Warning: TLS disabled for %s://%s. To force TLS over the plaintext HTTP port, "+
					"specify port 80 explicitly (https://%s:80).", config.Port, config.Host, config.Host)
			}
			if i == 0 {
				sharedConfig.Startup = []func() error{}
				sharedConfig.Shutdown = []func() error{}
			}
			configs = append(configs, config)
		}
	}

	// restore logging settings
	log.SetFlags(flags)

	// Group by address/virtualhosts
	return arrangeBindings(configs)
}

示例#24
文件: raftX.go 项目: izouxv/raftX

func main() {
	go func() {
		//http://localhost:6060/debug/pprof/
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()

	log.SetFlags(0)
	flag.Parse()
	if verbose {
		log.Print("Verbose logging enabled.")
	}
	if trace {
		raft.SetLogLevel(raft.Trace)
		log.Print("Raft trace debugging enabled.")
	} else if debug {
		raft.SetLogLevel(raft.Debug)
		log.Print("Raft debugging enabled.")
	}

	rand.Seed(time.Now().UnixNano())

	// Setup commands.
	raft.RegisterCommand(&command.SetCommand{})
	raft.RegisterCommand(&command.RemoveTmpDataCommand{})

	// Set the data directory.
	if flag.NArg() == 0 {
		flag.Usage()
		log.Fatal("Data path argument required")
	}
	path := flag.Arg(0)
	if err := os.MkdirAll(path, 0744); err != nil {
		log.Fatalf("Unable to create path: %v", err)
	}

	//	log.Fatalf("join: %v", join)
	//	log.Fatalf(" path: %v", path)

	log.SetFlags(log.LstdFlags)
	s := server.New(path, host, port)

	if true {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}
	addr := fmt.Sprintf("%s:%d", host, tcpSerPort)

	//log.Fatal(s.ListenAndServe(join, addr))
	s.ListenAndServe(join, addr)
	select {}
}

示例#25
文件: main.go 项目: rails0330/log

func main() {
	log.Println("hello")

	// You can see flags define in http://golang.org/pkg/log/#pkg-constants
	log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds | log.Lshortfile)
	log.Println("hello")

	// default format
	log.SetFlags(log.LstdFlags)

	// set prefix string
	log.SetPrefix("server1 ")
	log.Println("hello")
}

示例#26
文件: logging_test.go 项目: smartystreets/logging

func TestLoggingWithLoggerCapturesOutput(t *testing.T) {
	out := new(bytes.Buffer)
	log.SetOutput(out)
	log.SetFlags(0)
	defer log.SetOutput(os.Stdout)
	defer log.SetFlags(log.LstdFlags)

	thing := new(ThingUnderTest)
	thing.log = Capture()
	thing.Action()

	assertions.New(t).So(thing.log.Log.String(), should.Equal, "Hello, World!\n")
	assertions.New(t).So(out.Len(), should.Equal, 0)
}

示例#27
文件: logging_test.go 项目: smartystreets/logging

func TestLoggingWithDiscard(t *testing.T) {
	out := new(bytes.Buffer)
	log.SetOutput(out)
	log.SetFlags(0)
	defer log.SetOutput(os.Stdout)
	defer log.SetFlags(log.LstdFlags)

	thing := new(ThingUnderTest)
	thing.log = Discard()
	thing.Action()

	assertions.New(t).So(thing.log.Log.Len(), should.Equal, 0)
	assertions.New(t).So(out.Len(), should.Equal, 0)
}

示例#28
文件: harp.go 项目: jmptrader/harp

func init() {
	if debugf {
		log.SetFlags(log.Lshortfile)
	} else {
		log.SetFlags(0)
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	go func() {
		for range c {
			cleanCaches()
		}
	}()
}

示例#29
文件: webhook_windows.go 项目: jszalkowski/webhook

func init() {
	hooks = hook.Hooks{}

	flag.Parse()

	log.SetPrefix("[webhook] ")
	log.SetFlags(log.Ldate | log.Ltime)

	if !*verbose {
		log.SetOutput(ioutil.Discard)
	}

	log.Println("version " + version + " starting")

	// load and parse hooks
	log.Printf("attempting to load hooks from %s\n", *hooksFilePath)

	err := hooks.LoadFromFile(*hooksFilePath)

	if err != nil {
		if !*verbose && !*noPanic {
			log.SetOutput(os.Stdout)
			log.Fatalf("couldn't load any hooks from file! %+v\naborting webhook execution since the -verbose flag is set to false.\nIf, for some reason, you want webhook to start without the hooks, either use -verbose flag, or -nopanic", err)
		}

		log.Printf("couldn't load hooks from file! %+v\n", err)
	} else {
		log.Printf("loaded %d hook(s) from file\n", len(hooks))

		for _, hook := range hooks {
			log.Printf("\t> %s\n", hook.ID)
		}
	}
}

示例#30
文件: litmus_test_server.go 项目: tessavitabile/logkeeper

func main() {
	flag.Parse()
	log.SetFlags(0)
	fs := webdav.NewMemFS()
	ls := webdav.NewMemLS()
	http.Handle("/", &webdav.Handler{
		FileSystem: fs,
		LockSystem: ls,
		PropSystem: webdav.NewMemPS(fs, ls),
		Logger: func(r *http.Request, err error) {
			litmus := r.Header.Get("X-Litmus")
			if len(litmus) > 19 {
				litmus = litmus[:16] + "..."
			}

			switch r.Method {
			case "COPY", "MOVE":
				dst := ""
				if u, err := url.Parse(r.Header.Get("Destination")); err == nil {
					dst = u.Path
				}
				o := r.Header.Get("Overwrite")
				log.Printf("%-20s%-10s%-30s%-30so=%-2s%v", litmus, r.Method, r.URL.Path, dst, o, err)
			default:
				log.Printf("%-20s%-10s%-30s%v", litmus, r.Method, r.URL.Path, err)
			}
		},
	})

	addr := fmt.Sprintf(":%d", *port)
	log.Printf("Serving %v", addr)
	log.Fatal(http.ListenAndServe(addr, nil))
}

展开阅读全文