当前位置: 首页>>代码示例>>Golang>>正文


Golang logg.LogPanic函数代码示例

本文整理汇总了Golang中github.com/couchbaselabs/logg.LogPanic函数的典型用法代码示例。如果您正苦于以下问题:Golang LogPanic函数的具体用法?Golang LogPanic怎么用?Golang LogPanic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LogPanic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	//set logging
	logg.LogKeys[TagError] = true
	logg.LogKeys[TagDiff] = true

	if DEBUG == false {
		logg.LogKeys[TagLog] = true
	}

	kingpin.Parse()
	if *configFileName == "" {
		kingpin.Errorf("Config file name missing")
		return
	}
	configFile, err := os.Open(*configFileName)
	if err != nil {
		logg.LogPanic("Unable to open file: %v.  Err: %v", *configFileName, err.Error())
		return
	}
	defer configFile.Close()

	configReader := bufio.NewReader(configFile)

	err = parseConfigFile(configReader)
	if err != nil {
		logg.LogPanic("Erro parsing the config file: %v", err)
	}
}
开发者ID:Ryanair,项目名称:fr-mobile-resource-cache,代码行数:28,代码来源:main.go

示例2: authenticate

//authenticate uses a custom service to authenticate against a credentials repository like Active Directory
//and returns a session from sync gateway
func authenticate() AuthResponse {
	request, err := http.NewRequest("POST", authConfig.ServerURL, bytes.NewReader([]byte("{\"username\": \""+authConfig.Username+"\", \"password\": \""+authConfig.Password+"\"}")))

	if err != nil {
		logg.LogPanic("Error creating request: %v", err)
	}

	logRequest(request)

	response, err := globalHTTP.Do(request)
	if err != nil {
		logg.LogPanic("Error authenticating: %v", err)
	}

	defer response.Body.Close()

	authResponse := AuthResponse{}

	document, err := ioutil.ReadAll(response.Body)
	if err != nil {
		logg.LogPanic("Error reading contents: %v", err)
	}

	json.Unmarshal(document, &authResponse)

	return authResponse
}
开发者ID:Ryanair,项目名称:fr-mobile-resource-cache,代码行数:29,代码来源:rest.go

示例3: main

func main() {

	var preprocessor string
	flagFunc := func() {
		flag.StringVar(
			&preprocessor,
			"preprocessor",
			"identity",
			"The preprocessor to use, eg, stroke-width-transform",
		)

	}

	rabbitConfig := ocrworker.DefaultConfigFlagsOverride(flagFunc)

	// inifinite loop, since sometimes worker <-> rabbitmq connection
	// gets broken.  see https://github.com/tleyden/open-ocr/issues/4
	for {
		logg.LogTo("PREPROCESSOR_WORKER", "Creating new Preprocessor Worker")
		preprocessorWorker, err := ocrworker.NewPreprocessorRpcWorker(
			rabbitConfig,
			preprocessor,
		)
		if err != nil {
			logg.LogPanic("Could not create rpc worker: %v", err)
		}
		preprocessorWorker.Run()

		// this happens when connection is closed
		err = <-preprocessorWorker.Done
		logg.LogError(fmt.Errorf("Preprocessor Worker failed with error: %v", err))
	}

}
开发者ID:xhniu,项目名称:open-ocr,代码行数:34,代码来源:main.go

示例4: InitDbConnection

func (game *Game) InitDbConnection() {
	db, error := couch.Connect(SERVER_URL)
	if error != nil {
		logg.LogPanic("Error connecting to %v: %v", SERVER_URL, error)
	}
	game.db = db
}
开发者ID:jamesmauss,项目名称:checkerlution,代码行数:7,代码来源:gamecontroller.go

示例5: setAuth

func setAuth(request *http.Request) {
	if authConfig.Username != "" && authConfig.Password != "" {
		if authConfig.SimpleAuth {
			request.SetBasicAuth(authConfig.Username, authConfig.Password)
		} else {
			session := authenticate()
			layout := "2006-01-02T15:04:05Z07:00"
			expire, err := time.Parse(layout, session.Expires)
			if err != nil {
				logg.LogPanic("Error parsing time: %v", err)
			}

			rawCookie := []string{session.CookieName + "=" + session.SessionID}
			maxAge := 0
			secure := true
			httpOnly := true
			path := "/"

			cookie := http.Cookie{session.CookieName, session.SessionID, path, config.SyncURL, expire, expire.Format(time.UnixDate), maxAge, secure, httpOnly, rawCookie[0], rawCookie}

			request.AddCookie(&cookie)
		}
	}

}
开发者ID:Ryanair,项目名称:fr-mobile-resource-cache,代码行数:25,代码来源:rest.go

示例6: NewUuid

func NewUuid() string {
	u4, err := uuid.NewV4()
	if err != nil {
		logg.LogPanic("Error generating uuid", err)
	}
	return fmt.Sprintf("%s", u4)
}
开发者ID:maxxk,项目名称:neurgo,代码行数:7,代码来源:uuid.go

示例7: FollowChangesFeed

// Follow changes feed.  This will typically be run in its own goroutine.
func (c ChangesListener) FollowChangesFeed() {

	logg.LogTo("CHANGES", "going to follow changes feed")

	var since interface{}

	handleChange := func(reader io.Reader) interface{} {
		logg.LogTo("CHANGES", "handleChange() callback called")
		changes, err := decodeChanges(reader)
		if err != nil {
			// it's very common for this to timeout while waiting for new changes.
			// since we want to follow the changes feed forever, just log an error
			logg.LogTo("CHANGES", "%T decoding changes: %v.", err, err)
			return since
		}
		c.processChanges(changes)

		since = changes.LastSequence
		logg.LogTo("CHANGES", "returning since: %v", since)
		return since

	}

	options := map[string]interface{}{}
	options["feed"] = "longpoll"

	logg.LogTo("CHANGES", "Following changes feed: %+v.", options)

	// this will block until the handleChange callback returns nil
	c.Database.Changes(handleChange, options)

	logg.LogPanic("Changes listener died -- this should never happen")

}
开发者ID:bryanyzhu,项目名称:elastic-thought,代码行数:35,代码来源:changes_listener.go

示例8: generateOffspring

func (pt *PopulationTrainer) generateOffspring(population []EvaluatedCortex) (withOffspring []EvaluatedCortex) {

	withOffspring = make([]EvaluatedCortex, 0)
	withOffspring = append(withOffspring, population...)

	for _, evaldCortex := range population {

		cortex := evaldCortex.Cortex
		offspringCortex := cortex.Copy()

		offspringNodeIdStr := fmt.Sprintf("cortex-%s", ng.NewUuid())
		offspringCortex.NodeId = ng.NewCortexId(offspringNodeIdStr)

		succeeded, _ := pt.CortexMutator(offspringCortex)
		if !succeeded {
			logg.LogPanic("Unable to mutate cortex: %v", offspringCortex)
		}

		evaldCortexOffspring := EvaluatedCortex{
			Cortex:              offspringCortex,
			ParentId:            cortex.NodeId.UUID,
			CreatedInGeneration: pt.CurrentGeneration,
			Fitness:             0.0,
		}

		withOffspring = append(withOffspring, evaldCortexOffspring)

	}

	return

}
开发者ID:maxxk,项目名称:neurvolve,代码行数:32,代码来源:population_trainer.go

示例9: DbConnection

// Connect to db based on url stored in config, or panic if not able to connect
func (c Configuration) DbConnection() couch.Database {
	db, err := couch.Connect(c.DbUrl)
	if err != nil {
		err = errors.New(fmt.Sprintf("Error %v | dbUrl: %v", err, c.DbUrl))
		logg.LogPanic("%v", err)
	}
	return db
}
开发者ID:bryanyzhu,项目名称:elastic-thought,代码行数:9,代码来源:configuration.go

示例10: unmarshalCortex

func unmarshalCortex(pathToCortex string) *ng.Cortex {

	cortex, err := ng.NewCortexFromJSONFile(pathToCortex)
	if err != nil {
		logg.LogPanic("Error reading cortex from: %v.  Err: %v", pathToCortex, err)
	}
	return cortex

}
开发者ID:maxxk,项目名称:neurgo,代码行数:9,代码来源:nnviewer.go

示例11: makeHandler

func makeHandler(method handlerMethod) http.Handler {
	return http.HandlerFunc(func(r http.ResponseWriter, rq *http.Request) {
		h := newHandler(r, rq)
		err := h.invoke(method)
		if err != nil {
			logg.LogPanic("Error creating http handler: %v", err)
		}
	})
}
开发者ID:vladoatanasov,项目名称:sg-auth-server,代码行数:9,代码来源:handler.go

示例12: parseConfigFile

func parseConfigFile(r io.Reader) {
	config = Config{}

	decoder := json.NewDecoder(r)

	if err := decoder.Decode(&config); err != nil {
		logg.LogPanic("Error parsing config file: %v", err)
	}
}
开发者ID:vladoatanasov,项目名称:sg-auth-server,代码行数:9,代码来源:server.go

示例13: DisabledTestOcrHttpHandlerIntegration

// This test assumes that rabbit mq is running
func DisabledTestOcrHttpHandlerIntegration(t *testing.T) {

	rabbitConfig := rabbitConfigForTests()

	err := spawnOcrWorker(rabbitConfig)
	if err != nil {
		logg.LogPanic("Could not spawn ocr worker")
	}

	// add a handler to serve up an image from the filesystem.
	http.HandleFunc("/img", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "refactoring.png")
	})

	http.Handle("/ocr", NewOcrHttpHandler(rabbitConfig))

	go http.ListenAndServe(":8081", nil)

	logg.LogTo("TEST", "test1")

	ocrRequest := OcrRequest{
		ImgUrl:     "http://localhost:8081/img",
		EngineType: ENGINE_MOCK,
	}
	jsonBytes, err := json.Marshal(ocrRequest)
	if err != nil {
		logg.LogPanic("Could not marshal OcrRequest")
	}

	reader := bytes.NewReader(jsonBytes)

	resp, err := http.Post("http://localhost:8081/ocr", "application/json", reader)
	assert.True(t, err == nil)
	logg.LogTo("TEST", "resp: %v", resp)

	// connect to it via http client
	logg.LogTo("TEST", "Sleep for 60s")
	time.Sleep(time.Second * 60)

	// make sure get expected result

	assert.True(t, true)
}
开发者ID:priestd09,项目名称:open-ocr,代码行数:44,代码来源:ocr_http_handler_test.go

示例14: startWebServer

func startWebServer() {
	sock, err := net.Listen("tcp", ":"+fmt.Sprintf("%d", webPort))
	if err != nil {
		logg.LogPanic("Error starting web server : %v", err)
	}
	go func() {
		fmt.Println("HTTP now available at port ", webPort)
		http.Serve(sock, nil)
	}()

}
开发者ID:Ryanair,项目名称:fr-mobile-resource-cache,代码行数:11,代码来源:main.go

示例15: confirmDeliveryWorker

func confirmDeliveryWorker(ack, nack chan uint64) {
	logg.LogTo("OCR_WORKER", "awaiting delivery confirmation ...")
	select {
	case tag := <-ack:
		logg.LogTo("OCR_WORKER", "confirmed delivery, tag: %v", tag)
	case tag := <-nack:
		logg.LogTo("OCR_WORKER", "failed to confirm delivery: %v", tag)
	case <-time.After(RPC_RESPONSE_TIMEOUT):
		// this is bad, the worker will probably be dsyfunctional
		// at this point, so panic
		logg.LogPanic("timeout trying to confirm delivery")
	}
}
开发者ID:xhniu,项目名称:open-ocr,代码行数:13,代码来源:ocr_rpc_worker.go


注:本文中的github.com/couchbaselabs/logg.LogPanic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。