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


Golang logrus.Error函数代码示例

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


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

示例1: Init

func (t *HTTPProvider) Init(i interface{}) error {
	conf := i.(*HTTPConfig)

	// make sure the port is open
	l, err := net.Listen("tcp", conf.Listen)
	if err != nil {
		logrus.Error(err)

		// check to see if the busy port is due to another provider
		resp, err := std_http.Get("http://" + conf.Listen + ENDPOINT + "?init_check=true")
		if err != nil {
			return err
		}

		buff, _ := ioutil.ReadAll(resp.Body)
		if string(buff) != START_HANDSHAKE {
			return err

		}
	}

	// stop the test
	err = l.Close()
	if err != nil {
		logrus.Error(err)
		return err
	}

	// update the providers litening address
	t.listen = conf.Listen
	t.pool = event.NewEncodingPool(event.EncoderFactories[conf.Encoding], event.DecoderFactories[conf.Encoding], conf.MaxEncoders)

	return nil
}
开发者ID:postfix,项目名称:bangarang,代码行数:34,代码来源:http.go

示例2: Machines

func (v *vm) Machines() ([]vms.Machine, error) {
	resp, err := http.Get("http://" + v.server + ":8080/api/iaas")
	if err != nil {
		log.Error(err)
		return nil, err
	}
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Error(err)
		return nil, err
	}
	type Status struct {
		Id         string `json:"id"`
		Type       string `json:"type"`
		Attributes VmInfo
	}
	var State struct {
		Data []Status `json:"data"`
	}

	err = json.Unmarshal(body, &State)
	if err != nil {
		log.Error(err)
		return nil, err
	}
	var machines = make([]vms.Machine, len(State.Data))
	for i, val := range State.Data {
		machines[i] = &machine{id: val.Id, server: v.server}
	}
	return machines, nil
}
开发者ID:MeoBlodnasir,项目名称:community,代码行数:31,代码来源:vm.go

示例3: Get

func (i *Incident) Get(w http.ResponseWriter, r *http.Request) {
	w.Header().Add("content-type", "application/json")
	vars := mux.Vars(r)
	id, ok := vars["id"]
	if !ok {
		http.Error(w, "Must append incident id", http.StatusBadRequest)
		return
	}
	index := i.pipeline.GetIndex()

	// if the id is "*", fetch all outstanding incidents
	if id == "*" {
		all := index.ListIncidents()
		all = reduceStatusAbove(event.WARNING, all)
		buff, err := json.Marshal(makeKV(all))
		if err != nil {
			logrus.Error(err)
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
		w.Write(buff)
		return
	}

	// write out the found incident. The value will be null if nothing was found
	in := index.GetIncident([]byte(id))
	buff, err := json.Marshal(in)
	if err != nil {
		logrus.Error(err)
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	w.Write(buff)
}
开发者ID:postfix,项目名称:bangarang,代码行数:35,代码来源:incident.go

示例4: getTgtFromMountPoint

func getTgtFromMountPoint(mountpoint string) (target string, portal string) {
	log.Infof("Get iSCSI target for path %s", mountpoint)
	out, err := exec.Command("sudo", "df", "--output=source", mountpoint).CombinedOutput()
	if err != nil {
		log.Error("Failed to obtain device info from df cmd: ", err)
		return
	}

	device := "../../" + strings.Split(strings.Fields(string(out))[1], "/")[2]
	log.Debug("Formed the device: ", device)
	out, err = exec.Command("sudo", "ls", "-l", "/dev/disk/by-path").CombinedOutput()
	if err != nil {
		log.Error("Failed to list contents of /dev/disk/by-path/: ", err)
		return
	}
	lines := strings.Split(string(out), "\n")
	for _, line := range lines {
		log.Debugf("check line %s for %s...", line, device)
		if strings.Contains(line, device) {
			target = strings.Split((strings.Split(line, "-iscsi-")[1]), "-lun-")[0]
			portal = strings.Split((strings.Split(line, " ip-")[1]), "-iscsi-")[0]
		}
	}
	return
}
开发者ID:j-griffith,项目名称:cinder-docker-driver,代码行数:25,代码来源:utils.go

示例5: GetComputeSystemProperties

// GetComputeSystemProperties gets the properties for the compute system with the given ID.
func GetComputeSystemProperties(id string, flags uint32) (ComputeSystemProperties, error) {
	title := "hcsshim::GetComputeSystemProperties "

	csProps := ComputeSystemProperties{
		Stopped:           false,
		AreUpdatesPending: false,
	}

	logrus.Debugf("Calling proc")
	var buffer *uint16
	err := getComputeSystemProperties(id, flags, &buffer)
	if err != nil {
		err = makeError(err, title, "")
		logrus.Error(err)
		return csProps, err
	}
	propData := convertAndFreeCoTaskMemString(buffer)
	logrus.Debugf(title+" - succeeded output=%s", propData)

	if err = json.Unmarshal([]byte(propData), &csProps); err != nil {
		logrus.Error(err)
		return csProps, err
	}

	return csProps, nil
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:27,代码来源:getcomputesystemproperties.go

示例6: handlePullRequestReviewComment

func handlePullRequestReviewComment(w http.ResponseWriter, r *http.Request) {
	hook, err := github.ParsePullRequestReviewCommentHook(r.Body)
	if err != nil {
		logrus.Error(err)
		w.WriteHeader(500)
		return
	}

	if !hook.IsOpen() {
		w.WriteHeader(200)
		return
	}

	g := github.GitHub{
		AuthToken: config.GHToken,
		User:      config.GHUser,
	}

	if err := g.MoveTriageForward(hook.Repo, hook.PullRequest.Number, hook.Comment); err != nil {
		logrus.Error(err)
		w.WriteHeader(500)
		return
	}

	w.WriteHeader(204)
	return
}
开发者ID:KrunoKnego,项目名称:leeroy,代码行数:27,代码来源:handlers.go

示例7: processNetworkUpdate

func (c *controller) processNetworkUpdate(nws []*store.KVPair, prune *networkTable) {
	for _, kve := range nws {
		var n network
		err := json.Unmarshal(kve.Value, &n)
		if err != nil {
			log.Error(err)
			continue
		}
		if prune != nil {
			delete(*prune, n.id)
		}
		n.SetIndex(kve.LastIndex)
		c.Lock()
		existing, ok := c.networks[n.id]
		c.Unlock()
		if ok {
			existing.Lock()
			// Skip existing network update
			if existing.dbIndex != n.Index() {
				// Can't use SetIndex() since existing is locked.
				existing.dbIndex = n.Index()
				existing.dbExists = true
				existing.endpointCnt = n.endpointCnt
			}
			existing.Unlock()
			continue
		}

		if err = c.newNetworkFromStore(&n); err != nil {
			log.Error(err)
		}
	}
}
开发者ID:souravbh,项目名称:lattice-release,代码行数:33,代码来源:store.go

示例8: doUpdate

func (upd *updater) doUpdate(update model.ServiceUpdate) {
	svc := upd.services[update.ServiceKey]
	if svc == nil {
		if update.ServiceInfo == nil {
			return
		}

		svc, err := upd.config.newService(update, upd.errors)
		if err != nil {
			log.Error("adding service ", update.ServiceKey, ": ",
				err)
			return
		}

		upd.services[update.ServiceKey] = svc
	} else if update.ServiceInfo != nil {
		err := svc.update(update)
		if err != nil {
			log.Error("updating service ", update.ServiceKey, ": ",
				err)
			return
		}
	} else {
		delete(upd.services, update.ServiceKey)
		svc.close()
	}
}
开发者ID:squaremo,项目名称:ambergris,代码行数:27,代码来源:daemon.go

示例9: jfileAdd

// Takes a JFile, a JSON path (optional) and JSON data.
// Stores the JSON data. Returns true if successful.
func jfileAdd(L *lua.LState) int {
	jfile := checkJFile(L) // arg 1
	top := L.GetTop()
	jsonpath := "x"
	jsondata := ""
	if top == 2 {
		jsondata = L.ToString(2)
		if jsondata == "" {
			L.ArgError(2, "JSON data expected")
		}
	} else if top == 3 {
		jsonpath = L.ToString(2)
		// Check for { to help avoid allowing JSON data as a JSON path
		if jsonpath == "" || strings.Contains(jsonpath, "{") {
			L.ArgError(2, "JSON path expected")
		}
		jsondata = L.ToString(3)
		if jsondata == "" {
			L.ArgError(3, "JSON data expected")
		}
	}
	err := jfile.AddJSON(jsonpath, []byte(jsondata))
	if err != nil {
		if top == 2 || strings.HasPrefix(err.Error(), "invalid character") {
			log.Error("JSON data: ", err)
		} else {
			log.Error(err)
		}
	}
	L.Push(lua.LBool(err == nil))
	return 1 // number of results
}
开发者ID:sneakyweasel,项目名称:algernon,代码行数:34,代码来源:jfile.go

示例10: StatsListener

//StatsListener Listen for requests to serve server stats
func (s *StatsMgr) StatsListener(ip net.IP, port int, ctrlChan chan int) {
	s.wg.Add(1)

	go func() {
		r := mux.NewRouter()
		r.HandleFunc("/api/v1/stats/all", s.StatsAllJSON)
		svr := &http.Server{}
		svr.Handler = r
		tcpaddr, err := net.ResolveTCPAddr("tcp", net.JoinHostPort(ip.String(), strconv.Itoa(port)))
		if err != nil {
			log.Error("Stats Listener ", err)
			return
		}
		l, err := net.ListenTCP("tcp", tcpaddr)
		log.Printf("%s now listening on %s for incoming connections", strings.Join([]string{AppName, "Stats Listener"}, " "), tcpaddr.String())
		if err != nil {
			log.Error("Stats Listener ", err)
			return
		}
		if err := svr.Serve(l); err != nil {
			log.Errorln(err)
		}
		for item := range ctrlChan {
			if item == -1 {
				err = l.Close()
				if err != nil {
					log.Println(err)
				}
				s.wg.Done()
				log.Printf("%s shutting down", strings.Join([]string{AppName, "Stats Listener"}, " "))
				return
			}
		}
	}()
}
开发者ID:RobWC,项目名称:nitro-tftp,代码行数:36,代码来源:stats.go

示例11: configureAdvanced

func (riakNode *RiakNode) configureAdvanced(cepmdPort int) {

	fetchURI := fmt.Sprintf("%s/api/v1/clusters/%s/advancedConfig", riakNode.taskData.URI, riakNode.taskData.ClusterName)
	resp, err := http.Get(fetchURI)
	if err != nil {
		log.Error("Unable to fetch advanced config: ", err)
	}
	advancedConfig, err := ioutil.ReadAll(resp.Body)
	resp.Body.Close()
	if err != nil {
		log.Error("Unable to fetch advanced config: ", err)
	}

	tmpl, err := template.New("advanced").Parse(string(advancedConfig))

	if err != nil {
		log.Panic(err)
	}

	// Populate template data from the MesosTask
	vars := advancedTemplateData{}
	vars.CEPMDPort = cepmdPort
	file, err := os.OpenFile("root/riak/etc/advanced.config", os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0664)

	defer file.Close()
	if err != nil {
		log.Panic("Unable to open file: ", err)
	}

	err = tmpl.Execute(file, vars)

	if err != nil {
		log.Panic("Got error", err)
	}
}
开发者ID:glickbot,项目名称:riak-mesos,代码行数:35,代码来源:riak_node.go

示例12: GetFinishedTestRuns

// GetFinishedTestRuns returns a map of test UUIDS (keys) and the corresponding post-test metric data for those UUIDs (values)
// The metric data is stored as a string containing JSON text, so this is what's placed into this map (meaning JSON parsing is
// not performed in this function)
func (ac AgentCache) GetFinishedTestRuns() (map[string]string, error) {

	retmap := make(map[string]string)

	// Open connection
	db, err := sql.Open("sqlite3", ac.db_loc)
	if err != nil {
		log.Error(err)
		return retmap, errors.New("Error accessing sqlite cache for finished testruns")
	}
	defer db.Close()

	rows, err := db.Query(fmt.Sprint("select uuid, results from testruns where results != \"\" "))
	if err != nil {
		log.Error(err)
		return retmap, errors.New("Error creating query for selecting finished testruns")
	}

	defer rows.Close()
	for rows.Next() {
		var uuid, testdata string
		rows.Scan(&uuid, &testdata)
		log.Debug("Found ripe testrun: ", uuid)
		retmap[uuid] = testdata
	}

	return retmap, nil
}
开发者ID:twm1010,项目名称:todd,代码行数:31,代码来源:testruns.go

示例13: UpdateTestRunData

// UpdateTestRunData will update an existing testrun entry in the agent cache with the post-test
// metrics dataset that corresponds to that testrun (by testrun UUID)
func (ac AgentCache) UpdateTestRunData(uuid string, testData string) error {

	// Open connection
	db, err := sql.Open("sqlite3", ac.db_loc)
	if err != nil {
		log.Error(err)
		return errors.New("Error accessing sqlite cache for testrun update")
	}
	defer db.Close()

	// Begin Update
	tx, err := db.Begin()
	if err != nil {
		log.Error(err)
		return errors.New("Error beginning new UpdateTestRunData action")
	}

	stmt, err := tx.Prepare(fmt.Sprintf("update testruns set results = '%s' where uuid = '%s' ", testData, uuid))
	if err != nil {
		log.Error(err)
		return errors.New("Error preparing new UpdateTestRunData action")
	}
	defer stmt.Close()
	_, err = stmt.Exec()
	if err != nil {
		log.Error(err)
		return errors.New("Error executing new UpdateTestRunData action")
	}
	tx.Commit()

	log.Infof("Inserted test data for %s into cache", uuid)

	return nil
}
开发者ID:twm1010,项目名称:todd,代码行数:36,代码来源:testruns.go

示例14: Start

// start accepting connections and consume each of them as they come in
func (h *HTTPProvider) Start(p event.Passer) {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("Recovered in f", r)
		}
	}()
	std_http.HandleFunc(ENDPOINT, func(w std_http.ResponseWriter, r *std_http.Request) {

		// handle the case where a provider is restarting and needs to check if a listener is a bangarang provider or not
		if r.URL.Query().Get("init_check") == "true" {
			w.Write([]byte(START_HANDSHAKE))
		}
		buff, err := ioutil.ReadAll(r.Body)
		if err != nil {
			logrus.Error(err)
			std_http.Error(w, err.Error(), std_http.StatusInternalServerError)
			return
		}

		e := &event.Event{}
		err = h.pool.Decode(buff, e)

		if err != nil {
			logrus.Error(err)
			std_http.Error(w, err.Error(), std_http.StatusInternalServerError)
			return
		}
		p.Pass(e)
		logrus.Debug("Done processing http event")
	})

	logrus.Infof("Serving http listener on %s", h.listen)
	logrus.Fatal(std_http.ListenAndServe(h.listen, nil))
}
开发者ID:postfix,项目名称:bangarang,代码行数:35,代码来源:http.go

示例15: Get

// Get HTTP get method
func (p *EscalationConfig) Get(req *Request) {
	var conf *config.AppConfig
	p.pipeline.ViewConfig(func(cf *config.AppConfig) {
		conf = cf
	})
	vars := mux.Vars(req.r)
	id, ok := vars["id"]
	if !ok {
		logrus.Error("Must append escalation id", req.r.URL.String())
		http.Error(req.w, "must append escalation id", http.StatusBadRequest)
		return
	}

	if id == "*" {
		buff, err := json.Marshal(&conf.Escalations)
		if err != nil {
			logrus.Error(err)
			http.Error(req.w, err.Error(), http.StatusBadRequest)
			return
		}
		req.w.Write(buff)
		return
	}

	coll := conf.Escalations.Collection()
	logrus.Error(coll)
}
开发者ID:postfix,项目名称:bangarang,代码行数:28,代码来源:escalation_config.go


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