當前位置: 首頁>>代碼示例>>Golang>>正文


Golang seelog.Flush函數代碼示例

本文整理匯總了Golang中github.com/cihub/seelog.Flush函數的典型用法代碼示例。如果您正苦於以下問題:Golang Flush函數的具體用法?Golang Flush怎麽用?Golang Flush使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Flush函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: New

func New(endpoint []string, path string) *opt {
	cfg := client.Config{
		Endpoints:               endpoint,
		Transport:               client.DefaultTransport,
		HeaderTimeoutPerRequest: time.Second,
	}

	etcdClient, err := client.New(cfg)
	if err != nil {
		log.Errorf("new etcd client error: ", err)
		log.Flush()
		panic(0)
	}
	api := client.NewKeysAPI(etcdClient)
	resp, err := api.Get(context.Background(), "/swarm/docker/swarm/leader", nil)
	if err != nil {
		log.Errorf("get swarm leader error: %v", err)
		log.Flush()
		panic(0)
	}
	return &opt{
		Client:   etcdClient,
		Endpoint: endpoint,
		Path:     path,
		Api:      api,
		Leader:   fmt.Sprintf("http://%s", resp.Node.Value),
	}
}
開發者ID:yiqguo,項目名稱:beehive,代碼行數:28,代碼來源:etcd.go

示例2: read_to_chan

func (fr *TrecFileReader) read_to_chan(count int) (i int) {
	//Catch and log panics
	defer func() {
		if x := recover(); x != nil {
			log.Criticalf("Error in document %d of %s: %v", fr.docCounter, fr.filename, x)
			log.Flush()
		}
	}()

	for i := 0; i < count || count == -1; i++ {
		log.Debugf("Reading document %d from %s", i, fr.filename)
		doc, err := fr.read_next_doc()

		switch err {

		case io.EOF:
			log.Debugf("Got EOF for file %s", fr.filename)
			close(fr.documents)
			return i

		case nil:
			log.Debugf("Successfully read document %s", doc.Identifier())
			fr.documents <- doc

		default:
			log.Criticalf("Oh fuck...%v", err)
			panic(err)

		}
	}
	log.Infof("Returning")
	return i
}
開發者ID:Georgetown-IR-Lab,項目名稱:ocr-correction,代碼行數:33,代碼來源:trec.go

示例3: save

// Saves credential cache to disk. This writes to a temporary file first, then moves the file to the config location.
// This elminates from reading partially written credential files, and reduces (but does not eliminate) concurrent
// file access. There is not guarantee here for handling multiple writes at once since there is no out of process locking.
func (f *fileCredentialCache) save(registryCache *RegistryCache) error {
	defer log.Flush()
	file, err := ioutil.TempFile(f.path, ".config.json.tmp")
	if err != nil {
		return err
	}

	buff, err := json.MarshalIndent(registryCache, "", "  ")
	if err != nil {
		file.Close()
		os.Remove(file.Name())
		return err
	}

	_, err = file.Write(buff)

	if err != nil {
		file.Close()
		os.Remove(file.Name())
		return err
	}

	file.Close()
	// note this is only atomic when relying on linux syscalls
	os.Rename(file.Name(), f.fullFilePath())
	return err
}
開發者ID:concourse,項目名稱:docker-image-resource,代碼行數:30,代碼來源:file.go

示例4: TestGetPkgPath

func TestGetPkgPath(t *testing.T) {
	defer log.Flush()

	Convey("Give pkgPath a ptr", t, func() {
		c := &Closer{}
		name, pkgPath := GetPkgPath(c)
		So(name, ShouldEqual, "Closer")
		So(pkgPath, ShouldEqual, "github.com/vrecan/death")

	})

	Convey("Give pkgPath a interface", t, func() {
		var closable Closable
		closable = Closer{}
		name, pkgPath := GetPkgPath(closable)
		So(name, ShouldEqual, "Closer")
		So(pkgPath, ShouldEqual, "github.com/vrecan/death")
	})

	Convey("Give pkgPath a copy", t, func() {
		c := Closer{}
		name, pkgPath := GetPkgPath(c)
		So(name, ShouldEqual, "Closer")
		So(pkgPath, ShouldEqual, "github.com/vrecan/death")
	})
}
開發者ID:lcaballero,項目名稱:death,代碼行數:26,代碼來源:pkgPath_test.go

示例5: main

func main() {
	defer log.Flush()
	stdFormat()
	flag.Parse()

	if *clientId == "" {
		fmt.Fprintln(os.Stderr, "--client-id is not specified. See https://developers.google.com/drive/quickstart-go for step-by-step guide.")
		return
	}

	if *clientSecret == "" {
		fmt.Fprintln(os.Stderr, "--client-secret is not specified. See https://developers.google.com/drive/quickstart-go for step-by-step guide.")
		return
	}

	fs := gdrive.NewGDriveFileSystem(*clientId, *clientSecret)

	http.HandleFunc("/debug/gc", gcHandler)
	http.HandleFunc("/favicon.ico", notFoundHandler)
	http.HandleFunc("/", webdav.NewHandler(fs))

	fmt.Printf("Listening on %v\n", *addr)

	err := http.ListenAndServe(*addr, nil)
	if err != nil {
		log.Errorf("Error starting WebDAV server: %v", err)
	}
}
開發者ID:santeriv,項目名稱:gdrive-webdav,代碼行數:28,代碼來源:main.go

示例6: main

func main() {
	defer log.Flush()
	flag.Parse()
	args := flag.Args()

	if len(args) == 0 {
		usage(actions(nil))
		os.Exit(1)
	}

	logger, err := log.LoggerFromConfigAsString(config.Logger())
	if err != nil {
		die(err)
	}
	log.ReplaceLogger(logger)

	init, err := engine.New()
	if err != nil {
		die(err)
	}
	log.Info(args[0])
	actions := actions(init)
	action, ok := actions[args[0]]
	if !ok {
		usage(actions)
		os.Exit(1)
	}
	err = action.function()
	if err != nil {
		die(err)
	}
}
開發者ID:ColBT,項目名稱:amazon-ecs-init,代碼行數:32,代碼來源:ecs-init.go

示例7: TestSTreeMod

func TestSTreeMod(t *testing.T) {

	defer log.Flush()

	Convey("Test clone\n", t, func() {

		s, err := NewSTreeJson(strings.NewReader(`{"key1": "val1", "key.2": 1234, "key3": {"key4": true, "key5": -12.34}}`))
		So(err, ShouldBeNil)

		c, err := s.clone()
		So(err, ShouldBeNil)
		s["key1"] = "valMod"

		s3, err := s.STreeVal(".key3")
		s3["key4"] = false

		log.Debugf("Test clone - s: %v", s)
		log.Debugf("Test clone - c: %v", c)

		v1, err := c.StrVal(".key1")
		So(err, ShouldBeNil)
		So(v1, ShouldEqual, "val1")

		v2, err := c.BoolVal(".key3.key4")
		So(err, ShouldBeNil)
		So(v2, ShouldBeTrue)
	})
}
開發者ID:oldenbur,項目名稱:gostree,代碼行數:28,代碼來源:streemod_test.go

示例8: main

func main() {
	// Set up a done channel, that's shared by the whole pipeline.
	// Closing this channel will kill all pipeline goroutines
	//done := make(chan struct{})
	//defer close(done)

	// Set up logging
	initializeLogging()

	// Flush the log before we shutdown
	defer log.Flush()

	// Parse the command line flags
	config := parseCommandLineFlags()
	gamq.SetConfig(&config)

	if config.ProfilingEnabled {
		defer profile.Start(profile.CPUProfile).Stop()
	}

	log.Infof("Broker started on port: %d", gamq.Configuration.Port)
	log.Infof("Executing on: %d threads", runtime.GOMAXPROCS(-1))

	connectionManager := gamq.NewConnectionManager()
	connectionManager.Start()
}
開發者ID:FireEater64,項目名稱:gamq,代碼行數:26,代碼來源:gamq.go

示例9: Chew

func Chew(chewChan <-chan *messaging.Food, swallowChan chan *messaging.Food, wg *sync.WaitGroup) {
	log.Info("Let the chewing begin!")
	defer close(swallowChan)
	r := rep.NewReporter()
	r.RegisterStatWIndex("chew", "good")
	for msg := range chewChan {
		if nil != msg {
			//parsing work here probably change what our message type looks like when swallowed

			date := time.Unix(0, msg.GetTimeNano()).UTC()
			fmtDate := date.Format("2006-01-02")
			indexType := "all"
			customerId := "id" //should exist eventually
			index := "documents-" + customerId + "-" + fmtDate
			msg.Index = &index
			msg.IndexType = &indexType
			r.AddStatWIndex("chew", 1, "good")
			swallowChan <- msg
		}
	}
	log.Info("Done chewing")
	log.Flush()
	wg.Done()

}
開發者ID:vrecan,項目名稱:gomasticate,代碼行數:25,代碼來源:chew.go

示例10: main

func main() {

	if len(os.Args) < 3 {
		fmt.Fprintf(os.Stderr, "too few args,args form: <host port>\n")
		os.Exit(1)
	}
	host := os.Args[1]
	port, err := strconv.Atoi(os.Args[2])
	if err != nil {
		fmt.Fprintf(os.Stderr, "invalid port,need integer type,your input port: <port>\n", os.Args[2])
		os.Exit(1)
	}
	ctx := context.GetContext()
	currentServer := make(map[string]interface{})
	currentServer["id"] = "connector-1"
	currentServer["serverType"] = "connector"
	currentServer["host"] = "127.0.0.1"
	currentServer["port"] = 8888
	ctx.CurrentServer = currentServer
	defer seelog.Flush()

	tcp_cnct := tcp_connector.NewTcpConnector(host, port, nil)

	tcp_cnct.RegistNewConnCB(NewConnCB)
	tcp_cnct.RegistNewMsgCB(NewMsgCB)
	tcp_cnct.Start()
	ch := make(chan int)
	<-ch
}
開發者ID:liweisheng,項目名稱:server-framework,代碼行數:29,代碼來源:server.go

示例11: Tokens

func (tz *BadXMLTokenizer) Tokens() <-chan *Token {

	token_channel := make(chan *Token)
	log.Debugf("Created channel %v as part of Tokens(), with"+
		" Scanner = %v", token_channel, tz)

	go func(ret chan *Token, tz *BadXMLTokenizer) {
		for {
			log.Tracef("Scanner calling Next()")
			tok, err := tz.Next()
			log.Tracef("scanner.Next() returned %s, %v", tok, err)
			switch err {
			case nil:
				log.Debugf("Pushing %s into token channel %v",
					tok, ret)
				ret <- tok
			case io.EOF:
				log.Debugf("received EOF, closing channel")
				close(ret)
				log.Debugf("Closed.")
				log.Flush()
				return
				panic("I should have exited the goroutine but " +
					"didn't")
			}
		}
	}(token_channel, tz)

	return token_channel
}
開發者ID:Georgetown-IR-Lab,項目名稱:ocr-correction,代碼行數:30,代碼來源:tokenizer.go

示例12: adaptiveMain

func adaptiveMain() {
	defer log.Flush()
	loadAdaptiveConfig()
	testMsgIntensity(1)
	testMsgIntensity(5)
	testMsgIntensity(10)
}
開發者ID:Krave-n,項目名稱:seelog-examples,代碼行數:7,代碼來源:adaptive_main.go

示例13: libWithSealogMain

func libWithSealogMain() {
	defer library.FlushLog()
	defer log.Flush()
	loadAppConfig()
	log.Info("App started")
	log.Info("Config loaded")

	// Disable library log
	log.Info("* Disabled library log test")
	library.DisableLog()
	calcF2()
	log.Info("* Disabled library log tested")

	// Use a special logger for library
	log.Info("* Special output test")
	specialOutputConfig()
	calcF2()
	log.Info("* Special output tested")

	// Use the same logger for both app and library
	log.Info("* Same output test")
	sameOutputConfig()
	calcF2()
	log.Info("* Same output tested")

	log.Info("App finished")
}
開發者ID:cihub,項目名稱:seelog-examples,代碼行數:27,代碼來源:lib_with_sl_main.go

示例14: exitOnError

func exitOnError(e error) {
	if e != nil {
		log.Errorf("Received error '%s'", e.Error())
		log.Flush()
		os.Exit(1)
	}
}
開發者ID:evaluation-alex,項目名稱:gosync,代碼行數:7,代碼來源:main.go

示例15: main

func main() {
	defer log.Flush()

	clientId := os.Getenv("MONDO_CLIENT_ID")
	clientSecret := os.Getenv("MONDO_CLIENT_SECRET")
	userName := os.Getenv("MONDO_USERNAME")
	password := os.Getenv("MONDO_PASSWORD")

	// Authenticate with Mondo, and return an authenticated MondoClient.
	client, err := mondo.Authenticate(clientId, clientSecret, userName, password)
	if err != nil {
		panic(err)
	}

	// Retrieve all of the accounts.
	acs, err := client.Accounts()
	if err != nil {
		panic(err)
	}

	// Grab our account ID.
	accountId := acs[0].ID

	if _, err := client.RegisterWebhook(accountId, "YOUR_URL_HERE"); err != nil {
		log.Errorf("Error registering webhook: %v", err)
	}
}
開發者ID:radeksimko,項目名稱:go-mondo,代碼行數:27,代碼來源:main.go


注:本文中的github.com/cihub/seelog.Flush函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。