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


Golang seelog.Error函數代碼示例

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


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

示例1: PusherProto

//Simple pusher for testing
func PusherProto(count int, finished chan int, msg *messaging.Food, port int) {
	log.Info("Starting pusher")
	socket, err := nano.NewPushSocket()
	if nil != err {
		log.Error(err)
	}
	defer socket.Close()
	socket.SetSendTimeout(500 * time.Millisecond)
	sport := strconv.Itoa(port)
	_, err = socket.Connect("tcp://localhost:" + sport)
	if nil != err {
		log.Error(err)
		return
	}
	log.Info("Connected and ready to send data")
	tot := 0
	for {
		bytes, _ := msg.Marshal()
		_, err := socket.Send(bytes, 0) //blocking
		if nil != err {
			log.Error(err)
			continue
		} else {
			tot++
		}
		if tot >= count {
			break
		}
	}
	log.Info("Finished sending data exiting")
	finished <- tot
}
開發者ID:vrecan,項目名稱:gomasticate,代碼行數:33,代碼來源:pusher.go

示例2: Pusher

//Simple pusher for testing
func Pusher(count int, finished chan int, port int) {
	socket, err := nano.NewPushSocket()
	if nil != err {
		log.Error(err)
	}
	defer socket.Close()
	sport := strconv.Itoa(port)
	_, err = socket.Connect("tcp://localhost:" + sport)
	if nil != err {
		log.Error(err)
		return
	}
	log.Info("Connected and ready to send data")
	tot := 0
	bytes := []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8', 'x', 'f', 'c', 'x', 'f'}
	for {
		_, err := socket.Send(bytes, 0) //blocking
		if nil != err {
			log.Error(err)
		} else {
			tot++
		}
		if tot >= count {
			break
		}
	}
	finished <- tot
}
開發者ID:vrecan,項目名稱:gomasticate,代碼行數:29,代碼來源:pusher.go

示例3: Bulk

func (s *ESAPIV0) Bulk(data *bytes.Buffer) {
	if data == nil || data.Len() == 0 {
		return
	}
	data.WriteRune('\n')
	url := fmt.Sprintf("%s/_bulk", s.Host)

	client := &http.Client{}
	reqest, _ := http.NewRequest("POST", url, data)
	if s.Auth != nil {
		reqest.SetBasicAuth(s.Auth.User, s.Auth.Pass)
	}
	resp, errs := client.Do(reqest)
	if errs != nil {
		log.Error(errs)
		return
	}

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Error(err)
		return
	}
	log.Trace(url, string(body))
	defer resp.Body.Close()
	defer data.Reset()
	if resp.StatusCode != 200 {
		log.Errorf("bad bulk response: %s %s", body, resp.StatusCode)
		return
	}
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:31,代碼來源:v0.go

示例4: setInitLogging

func setInitLogging(logLevel string) {

	logLevel = strings.ToLower(logLevel)

	testConfig := `
	<seelog  type="sync" minlevel="`
	testConfig = testConfig + logLevel
	testConfig = testConfig + `">
		<outputs formatid="main">
			<filter levels="error">
				<file path="./log/gopa.log"/>
			</filter>
			<console formatid="main" />
		</outputs>
		<formats>
			<format id="main" format="[%Date(01-02) %Time] [%LEV] [%File:%Line,%FuncShort] %Msg%n"/>
		</formats>
	</seelog>`

	logger, err := log.LoggerFromConfigAsString(testConfig)
	if err != nil {
		log.Error("init config error,", err)
	}
	err = log.ReplaceLogger(logger)
	if err != nil {
		log.Error("init config error,", err)
	}
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:28,代碼來源:log.go

示例5: routine

func (this *RESTTransceiver) routine() {
	errors := 0
	onHTTPError := func(err error) {
		log.Error(err)
		errors += 1
		time.Sleep(time.Duration(errors) * time.Second)
	}
	onActionError := func(err error) {
		log.Error(err)
	}
	for {
		action, err := getAction(this.Client, this.OrchestratorURL, this.EntityID)
		if err != nil {
			onHTTPError(err)
			continue
		}
		err = deleteAction(this.Client, this.OrchestratorURL, action)
		if err != nil {
			onHTTPError(err)
			continue
		}
		err = this.onAction(action)
		if err != nil {
			onActionError(err)
			continue
		}
		errors = 0
	}
}
開發者ID:terminiter,項目名稱:earthquake,代碼行數:29,代碼來源:resttransceiver.go

示例6: main

func main() {
	f, err := os.Open("ok.txt")
	if err != nil {
		log.Info(err)
		return
	}
	defer f.Close()
	stat, err := f.Stat()
	if err != nil {
		log.Error("stat err")
	}
	data := make([]byte, stat.Size())
	_, err = f.Read(data)
	if err != nil {
		log.Error("read err")
	}
	dataStr := string(data)

	log.Info(dataStr)

	dirInfo()

	demoList()

}
開發者ID:dongwq,項目名稱:go-demo,代碼行數:25,代碼來源:fileIO.go

示例7: initLogger

func initLogger() {
	var err error

	// 初始化raven
	if cfg.Sentry != "" {
		Raven, err = raven.NewClient(cfg.Sentry, nil)
		if err != nil {
			log.Error("Init Sentry Error:", err)
		}
	}

	// 初始化logger
	if cfg.Logger != "" {
		// 自定義一個seelog raven receiver
		receiver := &RavenReciver{Client: Raven}
		parseParams := &log.CfgParseParams{
			CustomReceiverProducers: map[string]log.CustomReceiverProducer{
				"sentry": func(log.CustomReceiverInitArgs) (log.CustomReceiver, error) {
					return receiver, nil
				},
			},
		}
		if logger, err := log.LoggerFromParamConfigAsFile(cfg.Logger, parseParams); err == nil {
			log.ReplaceLogger(logger)
		} else {
			log.Error("Parse Logger Error: ", err)
		}

	}

}
開發者ID:jiehua233,項目名稱:ginserver,代碼行數:31,代碼來源:main.go

示例8: NewFileReadWorker

func (m *Migrator) NewFileReadWorker(pb *pb.ProgressBar, wg *sync.WaitGroup) {
	log.Debug("start reading file")
	f, err := os.Open(m.Config.DumpInputFile)
	if err != nil {
		log.Error(err)
		return
	}

	defer f.Close()
	r := bufio.NewReader(f)
	lineCount := 0
	for {
		line, err := r.ReadString('\n')
		if io.EOF == err || nil != err {
			break
		}
		lineCount += 1
		js := map[string]interface{}{}

		//log.Trace("reading file,",lineCount,",", line)
		err = json.Unmarshal([]byte(line), &js)
		if err != nil {
			log.Error(err)
			continue
		}
		m.DocChan <- js
		pb.Increment()
	}

	defer f.Close()
	log.Debug("end reading file")
	close(m.DocChan)
	wg.Done()
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:34,代碼來源:file.go

示例9: GetConfig

func GetConfig() (currConfig config, err error) {

	//Open the config file. Defer to closing it when the function goes out of scope
	configFile, err := os.Open("config/env.json")
	defer configFile.Close()

	//If we had an error log it and return our error
	if err != nil {
		log.Error("Problem grabbing configuration", err)
		return
	}

	// Create a json parser for this file
	jsonParser := json.NewDecoder(configFile)

	//This is a good golang pattern to use:
	// grab the error from the Decode call and if the err is not null log
	if err = jsonParser.Decode(&currConfig); err != nil {
		log.Error("Problem parsing configuration", err)
		return
	}

	return currConfig, err

}
開發者ID:4nthem,項目名稱:State,代碼行數:25,代碼來源:config.go

示例10: processFile

func processFile(req uploadRequest, db *database.DB, store *storage.Store) {
	defer req.file.Close()

	epub, err := openMultipartEpub(req.file)
	if err != nil {
		log.Warn("Not valid epub uploaded file ", req.filename, ": ", err)
		return
	}
	defer epub.Close()

	book, id := parseFile(epub, store)
	req.file.Seek(0, 0)
	size, err := store.Store(id, req.file, EPUB_FILE)
	if err != nil {
		log.Error("Error storing book (", id, "): ", err)
		return
	}

	book["filesize"] = size
	err = db.AddBook(book)
	if err != nil {
		log.Error("Error storing metadata (", id, "): ", err)
		return
	}
	log.Info("File uploaded: ", req.filename)
}
開發者ID:ohhdemgirls,項目名稱:trantor,代碼行數:26,代碼來源:upload.go

示例11: NextScroll

func (s *ESAPIV0) NextScroll(scrollTime string, scrollId string) (*Scroll, error) {
	//  curl -XGET 'http://es-0.9:9200/_search/scroll?scroll=5m'
	id := bytes.NewBufferString(scrollId)
	url := fmt.Sprintf("%s/_search/scroll?scroll=%s&scroll_id=%s", s.Host, scrollTime, id)
	resp, body, errs := Get(url, s.Auth, s.HttpProxy)
	if errs != nil {
		log.Error(errs)
		return nil, errs[0]
	}

	if resp.StatusCode != 200 {
		return nil, errors.New(body)
	}

	defer resp.Body.Close()

	log.Trace("next scroll,", url, body)

	// decode elasticsearch scroll response
	scroll := &Scroll{}
	err := json.Unmarshal([]byte(body), &scroll)
	if err != nil {
		log.Error(body)
		log.Error(err)
		return nil, err
	}

	return scroll, nil
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:29,代碼來源:v0.go

示例12: sendConsumerGroupStatusNotify

func (emailer *EmailNotifier) sendConsumerGroupStatusNotify() error {
	var bytesToSend bytes.Buffer
	log.Debug("send email")

	msgs := make([]Message, len(emailer.Groups))
	i := 0
	for group, msg := range emailer.groupMsgs {
		msgs[i] = msg
		delete(emailer.groupMsgs, group)
		i++
	}

	err := emailer.template.Execute(&bytesToSend, struct {
		From    string
		To      string
		Results []Message
	}{
		From:    emailer.From,
		To:      emailer.To,
		Results: msgs,
	})
	if err != nil {
		log.Error("Failed to assemble email:", err)
		return err
	}

	err = smtp.SendMail(fmt.Sprintf("%s:%v", emailer.Server, emailer.Port),
		emailer.auth, emailer.From, []string{emailer.To}, bytesToSend.Bytes())
	if err != nil {
		log.Error("Failed to send email message:", err)
		return err
	}
	return nil
}
開發者ID:Magnetme,項目名稱:Burrow,代碼行數:34,代碼來源:email_notifier.go

示例13: Get

func (fs *GDriveFileSystem) Get(p string) (webdav.StatusCode, io.ReadCloser, int64) {
	pFile := fs.getFile(p, false)
	if pFile == nil {
		return webdav.StatusCode(404), nil, -1
	}

	f := pFile.file
	downloadUrl := f.DownloadUrl
	log.Debug("downloadUrl=", downloadUrl)
	if downloadUrl == "" {
		log.Error("No download url: ", f)
		return webdav.StatusCode(500), nil, -1
	}

	req, err := http.NewRequest("GET", downloadUrl, nil)
	if err != nil {
		log.Error("NewRequest ", err)
		return webdav.StatusCode(500), nil, -1
	}

	resp, err := fs.transport.RoundTrip(req)
	if err != nil {
		log.Error("RoundTrip ", err)
		return webdav.StatusCode(500), nil, -1
	}

	return webdav.StatusCode(200), resp.Body, f.FileSize
}
開發者ID:santeriv,項目名稱:gdrive-webdav,代碼行數:28,代碼來源:gdrive.go

示例14: dial

func dial() *net.UDPConn {
	err, host := config.GetStringMapString("udp", "host")
	if err != nil {
		log.Error("can't find udp host")
		os.Exit(0)
	}
	err, port := config.GetStringMapString("udp", "port")
	if err != nil {
		log.Error("can't find udp port")
		os.Exit(0)
	}
	raddr, err := net.ResolveUDPAddr("udp", host+":"+port)
	if err != nil {
		log.Error("connect udp %s:%s error\n", host, port)
		os.Exit(0)
	}
	conn, err := net.DialUDP("udp", nil, raddr)
	if err != nil {
		log.Error("connect udp %s:%s error\n", host, port)
		os.Exit(0)
	}
	// bump up the packet size for large log lines
	err = conn.SetWriteBuffer(writeBuffer)
	if err != nil {
		log.Error("connect udp %s:%s error\n", host, port)
		os.Exit(0)
	}
	return conn
}
開發者ID:yiqguo,項目名稱:LogCollect,代碼行數:29,代碼來源:udp.go

示例15: handleCopy

func (h *handler) handleCopy(r *http.Request) StatusCode {
	var err error

	p := url2path(r.URL)

	strDepth := r.Header.Get("Depth")
	depth := 9999999
	if strDepth != "" && strDepth != "infinity" {
		depth, err = strconv.Atoi(strDepth)
		if err != nil {
			log.Error("Can't parse depth ", err)
			return StatusCode(500)
		}
	}

	dest, err := urlstring2path(r.Header.Get("Destination"))
	if err != nil {
		log.Error("Can't parse dest ", err)
		return StatusCode(500)
	}

	overwrite := true

	if r.Header.Get("Overwrite") == "F" {
		overwrite = false
	}

	log.Debug("Copy from ", p, " to ", dest, " depth=", depth, " overwrite=", overwrite)

	return StatusCode(h.fs.Copy(p, dest, depth, overwrite))
}
開發者ID:santeriv,項目名稱:gdrive-webdav,代碼行數:31,代碼來源:webdav.go


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