当前位置: 首页>>代码示例>>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;未经允许,请勿转载。