• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang logg.LogPanic函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

func main() {
	startWebServer()

	resources, _ := getLocalResources()
	patchFiles(resources)

	dirList, err := getDirectories()
	if err != nil {
		logg.LogPanic("Error scanning directories", err)
	}

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


示例17: newFolderWatcher

func newFolderWatcher(dirList []string) {
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	defer watcher.Close()

	done := make(chan bool)
	go func() {
		for {
			select {
			case event := <-watcher.Events:
				logg.LogTo(TagLog, "New Event %v", event)

				if event.Op&fsnotify.Chmod == fsnotify.Chmod {
					f, _ := os.Stat(event.Name)
					if isJSON(f.Name()) && !isHidden(f.Name()) {
						err = NewLocalDocument(event.Name, &resources)
					} else if !isHidden(f.Name()) {
						err = NewLocalAttachment(event.Name, &resources)
					}

					if err != nil {
						logg.LogTo(TagError, "%v", err)
					} else {
						patchFiles(resources)
					}
				}

				if event.Op&fsnotify.Rename == fsnotify.Rename {
					documentID := getDocumentID(event.Name)
					err := deleteDocument(documentID)
					if err != nil {
						logg.LogTo(TagError, "Error deleting document : %v", err)
					}
				}
			case err := <-watcher.Errors:
				logg.LogTo(TagError, "%v", err)
			}
		}
	}()

	for _, dir := range dirList {
		logg.LogTo(TagLog, "attaching watcher to %s", dir)
		err = watcher.Add(dir)
		if err != nil {
			logg.LogPanic("Error attaching fs watcher : %v", err)
		}
	}
	<-done
}
开发者ID:Ryanair,项目名称:fr-mobile-resource-cache,代码行数:51,代码来源:main.go


示例18: scatterOutput

func (sensor *Sensor) scatterOutput(dataMessage *DataMessage) {

	if len(dataMessage.Inputs) == 0 {
		logg.LogPanic("cannot scatter empty data message")
	}

	for _, outboundConnection := range sensor.Outbound {
		logmsg := fmt.Sprintf("%v -> %v: %v", sensor.NodeId.UUID,
			outboundConnection.NodeId.UUID, dataMessage)
		logg.LogTo("NODE_PRE_SEND", logmsg)
		dataChan := outboundConnection.DataChan
		dataChan <- dataMessage
		logg.LogTo("NODE_POST_SEND", logmsg)
	}
}
开发者ID:maxxk,项目名称:neurgo,代码行数:15,代码来源:sensor.go


示例19: CreateRemoteUser

func (game *Game) CreateRemoteUser() {

	u4, err := uuid.NewV4()
	if err != nil {
		logg.LogPanic("Error generating uuid", err)
	}

	user := &User{
		Id:     fmt.Sprintf("user:%s", u4),
		TeamId: game.ourTeamId,
	}
	newId, newRevision, err := game.db.Insert(user)
	logg.LogTo("MAIN", "Inserted new user %v rev %v", newId, newRevision)

	user.Rev = newRevision
	game.user = *user

}
开发者ID:jamesmauss,项目名称:checkerlution,代码行数:18,代码来源:gamecontroller.go


示例20: init

func init() {
	// parse config file
	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)
	parseConfigFile(configReader)

	//set logging
	logg.LogKeys[logTag] = true
}
开发者ID:vladoatanasov,项目名称:sg-auth-server,代码行数:20,代码来源:server.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang logg.LogTo函数代码示例发布时间:2022-05-23
下一篇:
Golang logg.LogError函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap