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

Golang logrus.Debug函数代码示例

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

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



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

示例1: Update

// Update performs an update to the TUF repo as defined by the TUF spec
func (c *Client) Update() (*tuf.Repo, error) {
	// 1. Get timestamp
	//   a. If timestamp error (verification, expired, etc...) download new root and return to 1.
	// 2. Check if local snapshot is up to date
	//   a. If out of date, get updated snapshot
	//     i. If snapshot error, download new root and return to 1.
	// 3. Check if root correct against snapshot
	//   a. If incorrect, download new root and return to 1.
	// 4. Iteratively download and search targets and delegations to find target meta
	logrus.Debug("updating TUF client")
	err := c.update()
	if err != nil {
		logrus.Debug("Error occurred. Root will be downloaded and another update attempted")
		logrus.Debug("Resetting the TUF builder...")

		c.newBuilder = c.newBuilder.BootstrapNewBuilder()

		if err := c.downloadRoot(); err != nil {
			logrus.Debug("Client Update (Root):", err)
			return nil, err
		}
		// If we error again, we now have the latest root and just want to fail
		// out as there's no expectation the problem can be resolved automatically
		logrus.Debug("retrying TUF client update")
		if err := c.update(); err != nil {
			return nil, err
		}
	}
	return c.newBuilder.Finish()
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:31,代码来源:client.go


示例2: changeTargetMeta

func changeTargetMeta(repo *tuf.Repo, c changelist.Change) error {
	var err error
	switch c.Action() {
	case changelist.ActionCreate:
		logrus.Debug("changelist add: ", c.Path())
		meta := &data.FileMeta{}
		err = json.Unmarshal(c.Content(), meta)
		if err != nil {
			return err
		}
		files := data.Files{c.Path(): *meta}

		err = doWithRoleFallback(c.Scope(), func(role string) error {
			_, e := repo.AddTargets(role, files)
			return e
		})
		if err != nil {
			logrus.Errorf("couldn't add target to %s: %s", c.Scope(), err.Error())
		}

	case changelist.ActionDelete:
		logrus.Debug("changelist remove: ", c.Path())

		err = doWithRoleFallback(c.Scope(), func(role string) error {
			return repo.RemoveTargets(role, c.Path())
		})
		if err != nil {
			logrus.Errorf("couldn't remove target from %s: %s", c.Scope(), err.Error())
		}

	default:
		logrus.Debug("action not yet supported: ", c.Action())
	}
	return err
}
开发者ID:qingqi,项目名称:docker,代码行数:35,代码来源:helpers.go


示例3: processArgument

func (p *Parser) processArgument(argument string, parameter string) (processedParam bool) {
	processedParam = false

	// Only process if this argument has the "--" prefix as expected
	if len(argument) < 3 || argument[0] != '-' || argument[1] != '-' {
		log.Debug(fmt.Sprintf("Argument [%s] does not start with '--', skipping...", argument))
		return
	}

	// See if the next "argument" is actually a parameter for this argument
	// even if we don't find a match for the argument in the expected args
	if len(parameter) < 3 || parameter[0] != '-' || parameter[1] != '-' {
		log.Debug(fmt.Sprintf("Next argument [%s] does not start with '--', treating as a parameter", parameter))
		processedParam = true
	}

	// Now look for a match for this argument in the expected args
	argument = argument[2:]
	log.Debug(fmt.Sprintf("Looking for an args match for [%s]", argument))
	for _, expectedArg := range p.args {
		if expectedArg.LongForm == argument {
			log.Debug(fmt.Sprintf("Found a match: %s", expectedArg.String()))
			expectedArg.Present = true
			if processedParam == true {
				expectedArg.Param = parameter
			}
			break
		}
	}

	return
}
开发者ID:JHouk,项目名称:cli,代码行数:32,代码来源:parser.go


示例4: HandlePUT

// HTTP handler to allow clients to add/update schedules
func (a *API) HandlePUT(w http.ResponseWriter, r *http.Request) {

	log.Debug("Handling PUT")

	userID := r.Header.Get("user_id")

	defer r.Body.Close()

	log.Debug("going to decode schedule")
	decoder := json.NewDecoder(r.Body)
	proposal := types.Schedule{}
	err := decoder.Decode(&proposal)
	if err != nil {
		log.Warn("failed to decode proposed schedule: ", err)
		handleError(w, UnmarshalError)
		return
	}

	log.Debug("proposal: ", proposal)
	err = a.db.Put(userID, proposal)
	if err != nil {
		log.Warn("error putting: ", err)
		handleError(w, err)
		return
	}

	w.WriteHeader(200)
}
开发者ID:scheedule,项目名称:schedulestore,代码行数:29,代码来源:api.go


示例5: ExecIpmiToolRemote

// ExecIpmiToolRemote method runs ipmitool command on a remote system
func ExecIpmiToolRemote(request []byte, strct *LinuxOutOfBand, addr string) []byte {
	c, err := exec.LookPath("ipmitool")
	if err != nil {
		log.Debug("Unable to find ipmitool")
		return nil
	}

	a := []string{"-I", "lanplus", "-H", addr, "-U", strct.User, "-P", strct.Pass, "-b", strct.Channel, "-t", strct.Slave, "raw"}
	for i := range request {
		a = append(a, fmt.Sprintf("0x%02x", request[i]))
	}

	ret, err := exec.Command(c, a...).CombinedOutput()
	if err != nil {
		log.Debug("Unable to run ipmitool")
		return nil
	}

	returnStrings := strings.Split(string(ret), " ")
	rets := make([]byte, len(returnStrings))
	for ind, el := range returnStrings {
		value, _ := strconv.ParseInt(el, 16, 0)
		rets[ind] = byte(value)
	}

	return rets

}
开发者ID:XinDongIntel,项目名称:MyFirstGoProj,代码行数:29,代码来源:ipmitool.go


示例6: StartReadListening

func StartReadListening(readPort int, writePort int, defaultWriters []string, mapOperation SplitterMap) {
	// Create buffer to hold data
	queue := lane.NewQueue()
	MonitorServer(queue)
	// Start listening for writer destinations
	go StartWriteListening(queue, defaultWriters, writePort)

	socket, err := net.Listen("tcp", ":"+strconv.Itoa(readPort))
	if err != nil {
		logrus.Error(err)
	}
	// This will block the main thread
	for {
		// Begin trying to accept connections
		logrus.Debug("Awaiting Connection...")
		//Block and wait for listeners
		conn, err := socket.Accept()
		if err != nil {
			logrus.Error(err)
		} else {
			logrus.Debug("Accepted Connection...")
			go HandleReadConnection(conn, queue, writePort, mapOperation)
		}
	}
}
开发者ID:jmptrader,项目名称:splitter,代码行数:25,代码来源:server.go


示例7: toCommand

// helper function to encode the build step to
// a json string. Primarily used for plugins, which
// expect a json encoded string in stdin or arg[1].
func toCommand(s *State, n *parser.DockerNode) []string {
	p := payload{
		Workspace: s.Workspace,
		Repo:      s.Repo,
		Build:     s.Build,
		Job:       s.Job,
		Vargs:     n.Vargs,
	}

	y, err := yaml.Marshal(n.Vargs)
	if err != nil {
		log.Debug(err)
	}
	p.Vargs = map[string]interface{}{}
	err = yamljson.Unmarshal(y, &p.Vargs)
	if err != nil {
		log.Debug(err)
	}

	p.System = &plugin.System{
		Version: s.System.Version,
		Link:    s.System.Link,
	}

	b, _ := json.Marshal(p)
	return []string{"--", string(b)}
}
开发者ID:CiscoCloud,项目名称:drone-exec,代码行数:30,代码来源:utils.go


示例8: NewSnapshot

// NewSnapshot initilizes a SignedSnapshot with a given top level root
// and targets objects
func NewSnapshot(root *Signed, targets *Signed) (*SignedSnapshot, error) {
	logrus.Debug("generating new snapshot...")
	targetsJSON, err := json.Marshal(targets)
	if err != nil {
		logrus.Debug("Error Marshalling Targets")
		return nil, err
	}
	rootJSON, err := json.Marshal(root)
	if err != nil {
		logrus.Debug("Error Marshalling Root")
		return nil, err
	}
	rootMeta, err := NewFileMeta(bytes.NewReader(rootJSON), NotaryDefaultHashes...)
	if err != nil {
		return nil, err
	}
	targetsMeta, err := NewFileMeta(bytes.NewReader(targetsJSON), NotaryDefaultHashes...)
	if err != nil {
		return nil, err
	}
	return &SignedSnapshot{
		Signatures: make([]Signature, 0),
		Signed: Snapshot{
			SignedCommon: SignedCommon{
				Type:    TUFTypes[CanonicalSnapshotRole],
				Version: 0,
				Expires: DefaultExpires(CanonicalSnapshotRole),
			},
			Meta: Files{
				CanonicalRootRole:    rootMeta,
				CanonicalTargetsRole: targetsMeta,
			},
		},
	}, nil
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:37,代码来源:snapshot.go


示例9: startAgent

func startAgent(c Config) {
	for {
	Inner:
		for _, console := range c.Consoles {
			url := strings.Join([]string{"http://", console, ":", c.ConsolePort, "/agent"}, "")
			log.Debug("POSTing to URL: ", url)
			// JSON Post
			json, _ := json.Marshal(getData(c))
			log.Debug("POST ", string(json))
			req, err := http.NewRequest("POST", url, bytes.NewBuffer(json))
			req.Header.Set("X-Custom-Header", "myvalue")
			req.Header.Set("Content-Type", "application/json")

			client := &http.Client{}
			resp, err := client.Do(req)
			if err != nil {
				log.Warn("Failed to POST to ", url)
				continue Inner
			}
			defer resp.Body.Close() // Sleep for 1 minute before next POST
			log.Info("Successful POST to ", url)
			log.Debug("Response Status: ", resp.Status)
			log.Debug("Response Headers: ", resp.Header)
			body, _ := ioutil.ReadAll(resp.Body)
			log.Debug("Response Body: ", body)
		}
		time.Sleep(2 * time.Minute)
	}
}
开发者ID:malnick,项目名称:cata-agent,代码行数:29,代码来源:agent.go


示例10: Run

func (ns *NerveService) Run(stop <-chan bool) {
	defer servicesWaitGroup.Done()
	log.Debug("Service Running [", ns.Name, "]")
Loop:
	for {
		// Here The job to check, and report
		status, err := ns.Watcher.Check()
		if err != nil {
			log.Warn("Check error for Service [", ns.Name, "] [", err, "]")
		}
		ns.Reporter.Report(status)

		// Wait for the stop signal
		select {
		case hasToStop := <-stop:
			if hasToStop {
				log.Debug("Nerve: Service [", ns.Name, "]Run Close Signal Received")
			} else {
				log.Debug("Nerve: Service [", ns.Name, "]Run Close Signal Received (but a strange false one)")
			}
			break Loop
		default:
			time.Sleep(time.Millisecond * time.Duration(ns.CheckInterval))
		}
	}
	err := ns.Reporter.Destroy()
	if err != nil {
		log.Warn("Service [", ns.Name, "] has detected an error when destroying Reporter (", err, ")")
	}
	log.Debug("Service [", ns.Name, "] stopped")
}
开发者ID:cvasseur,项目名称:go-nerve,代码行数:31,代码来源:nerve_service.go


示例11: gracefulShutdown

//If we shut down without doing this stuff, we will lose some of the packet data
//still in the processing pipeline.
func gracefulShutdown(channels []chan *packetData, reChan chan tcpDataStruct, logChan chan dnsLogEntry) {

	var wait_time int = 3
	var numprocs int = len(channels)

	log.Debug("Draining TCP data...")

OUTER:
	for {
		select {
		case reassembledTcp := <-reChan:
			pd := NewTcpData(reassembledTcp)
			channels[int(reassembledTcp.IpLayer.FastHash())&(numprocs-1)] <- pd
		case <-time.After(3 * time.Second):
			break OUTER
		}
	}

	log.Debug("Stopping packet processing...")
	for i := 0; i < numprocs; i++ {
		close(channels[i])
	}

	log.Debug("waiting for log pipeline to flush...")
	close(logChan)

	for len(logChan) > 0 {
		wait_time--
		if wait_time == 0 {
			log.Debug("exited with messages remaining in log queue!")
			return
		}
		time.Sleep(time.Second)
	}
}
开发者ID:Phillipmartin,项目名称:gopassivedns,代码行数:37,代码来源:main.go


示例12: EndCreateHandler

// POST /events/end HTTP Handler
func EndCreateHandler(c web.C, w http.ResponseWriter, r *http.Request) {
	decoder := json.NewDecoder(r.Body)
	rbody := &endCreateReqBody{}

	// Decode JSON
	err := decoder.Decode(&rbody)
	if err != nil {
		log.Debug(err)
		http.Error(w, http.StatusText(400), 400)
		return
	}

	// Validate
	res, err := v.ValidateStruct(rbody)
	if err != nil {
		log.Debug(res)
		http.Error(w, http.StatusText(422), 422)
		return
	}

	// Publish event
	if err := events.PublishEndEvent(
		c.Env["REDIS"].(*redis.Client),
		rbody.Track,
		rbody.User); err != nil {

		log.Error(err)
		http.Error(w, http.StatusText(500), 500)
		return
	}

	// We got to the end - everything went fine!
	w.WriteHeader(201)
}
开发者ID:thisissoon,项目名称:FM-Perceptor,代码行数:35,代码来源:end.go


示例13: PopulateDB

// Populate the selected database with the data scraped from the term URL.
func PopulateDB(termURL, ip, port, dbName, collectionName string) error {
	scrapeDB := db.New(ip, port, dbName, collectionName)

	err := scrapeDB.Init()
	if err != nil {
		return err
	}

	log.Debug("purging database")
	scrapeDB.Purge()

	term, err := scrape.GetXML(termURL)

	courseChan := make(chan types.Class)

	go scrape.DigestAll(term, courseChan)

	for class := range courseChan {
		err = scrapeDB.Put(class)
		if err != nil {
			return err
		}
	}

	log.Debug("finished populating database")

	return nil
}
开发者ID:scheedule,项目名称:coursestore,代码行数:29,代码来源:scrape.go


示例14: Start

func Start(w http.ResponseWriter, r *http.Request) {
	vars, session, err := initSession(w, r)
	if err != nil {
		return
	}

	if *startSecretKey == "" || isValidToken(vars["CardId"], *startSecretKey) {
		log.Debugf("Valid Start page: %v", vars["CardId"])
		session.Values["cardId"] = vars["CardId"]
		sessions.Save(r, w)

		var fileName string

		if session.Values["admin"] == "1" {
			log.Debug("Sending Admin UI")
			fileName = root + "/admin.html"
		} else {
			log.Debug("Sending User UI")
			fileName = root + "/public.html"
		}
		f, err := os.Open(fileName)
		if err == nil {
			http.ServeContent(w, r, fileName, time.Time{}, f)
		} else {
			log.Error(err.Error())
			http.Error(w, err.Error(), http.StatusInternalServerError)
		}
	} else {
		log.Infof("Bad Start page: %v", vars["CardId"])
		err = templates["bad-cards.html"].Execute(w, nil)
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
		}
	}
}
开发者ID:BlueMasters,项目名称:thymio-captain,代码行数:35,代码来源:main.go


示例15: changeTargetMeta

func changeTargetMeta(repo *tuf.Repo, c changelist.Change) error {
	var err error
	switch c.Action() {
	case changelist.ActionCreate:
		logrus.Debug("changelist add: ", c.Path())
		meta := &data.FileMeta{}
		err = json.Unmarshal(c.Content(), meta)
		if err != nil {
			return err
		}
		files := data.Files{c.Path(): *meta}

		// Attempt to add the target to this role
		if _, err = repo.AddTargets(c.Scope(), files); err != nil {
			logrus.Errorf("couldn't add target to %s: %s", c.Scope(), err.Error())
		}

	case changelist.ActionDelete:
		logrus.Debug("changelist remove: ", c.Path())

		// Attempt to remove the target from this role
		if err = repo.RemoveTargets(c.Scope(), c.Path()); err != nil {
			logrus.Errorf("couldn't remove target from %s: %s", c.Scope(), err.Error())
		}

	default:
		logrus.Debug("action not yet supported: ", c.Action())
	}
	return err
}
开发者ID:mbentley,项目名称:notary,代码行数:30,代码来源:helpers.go


示例16: waitPortBinding

func waitPortBinding(watchedPort string, strictBinding bool) {
	for {
		p := procfs.Self()

		pids := []int{}

		if strictBinding {
			descendants, err := p.Descendants()
			if err != nil {
				log.Error(err)
				break
			}

			for _, p := range descendants {
				pids = append(pids, p.Pid)
			}
			log.Debug(pids)
		}

		binderPid, err := port.IsPortBound(watchedPort, pids)
		if err != nil {
			log.Error(err)
			break
		}
		log.Debug(binderPid)
		if binderPid != -1 {
			log.Debugf("port %s binded by pid %d (used strict check: %v)", watchedPort, binderPid, strictBinding)
			processStateChanged(notifier.StatusRunning)
			break
		}
		time.Sleep(200 * time.Millisecond)
	}
}
开发者ID:robinmonjo,项目名称:dock,代码行数:33,代码来源:main.go


示例17: stopListeners

// Stop all socket listeners
func (app *App) stopListeners() {
	if app.TCP != nil {
		app.TCP.Stop()
		app.TCP = nil
		logrus.Debug("[tcp] finished")
	}

	if app.Pickle != nil {
		app.Pickle.Stop()
		app.Pickle = nil
		logrus.Debug("[pickle] finished")
	}

	if app.UDP != nil {
		app.UDP.Stop()
		app.UDP = nil
		logrus.Debug("[udp] finished")
	}

	if app.CarbonLink != nil {
		app.CarbonLink.Stop()
		app.CarbonLink = nil
		logrus.Debug("[carbonlink] finished")
	}
}
开发者ID:xyntrix,项目名称:go-carbon,代码行数:26,代码来源:app.go


示例18: ValidateUsername

//ValidateUsername checks if a username is already taken or not
func (service *Service) ValidateUsername(w http.ResponseWriter, request *http.Request) {
	username := request.URL.Query().Get("username")
	response := struct {
		Valid bool   `json:"valid"`
		Error string `json:"error"`
	}{
		Valid: true,
		Error: "",
	}
	valid := user.ValidateUsername(username)
	if !valid {
		log.Debug("Invalid username format:", username)
		response.Error = "invalid_username_format"
		response.Valid = false
		json.NewEncoder(w).Encode(&response)
		return
	}
	userMgr := user.NewManager(request)
	userExists, err := userMgr.Exists(username)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	if userExists {
		log.Debug("username ", username, " already taken")
		response.Error = "duplicate_username"
		response.Valid = false
	}
	json.NewEncoder(w).Encode(&response)
	return
}
开发者ID:itsyouonline,项目名称:identityserver,代码行数:32,代码来源:registration.go


示例19: StartWriteListening

func StartWriteListening(readQueue *lane.Queue, defaultWriters []string, writePort int) {
	cList := NewConnectionList()
	socket, err := net.Listen("tcp", ":"+strconv.Itoa(writePort))
	if err != nil {
		logrus.Error(err)
	}
	// Begin trying to connect to default endpoints
	for _, writer := range defaultWriters {
		logrus.Debug("Opening connections to endpoints...")
		conn, err := net.Dial("tcp", writer)
		if err != nil {
			logrus.Error(err)
		} else {
			logrus.Debug("Accepted Connection...")
			cList.AddConnection(conn)
			go HandleWriteConnections(cList, readQueue)
		}
	}

	for {
		// Begin trying to accept connections
		logrus.Debug("Awaiting Connection...")
		//Block and wait for listeners
		conn, err := socket.Accept()
		if err != nil {
			logrus.Error(err)
		} else {
			logrus.Debug("Accepted Connection...")
			cList.AddConnection(conn)
			go HandleWriteConnections(cList, readQueue)
		}
	}
}
开发者ID:jmptrader,项目名称:splitter,代码行数:33,代码来源:server.go


示例20: Agent

// The container index
func Agent(w http.ResponseWriter, r *http.Request) {
	log.Debug("/agent POST")
	// Make a channel to dump our requests asynchronously
	respCh := make(chan *HttpPost)

	// Make an array of hostData to feed into
	hostDataArry := []*HttpPost{}

	// Spawn a proc to dump the data into our channel
	go func(r *http.Request) {
		var newData HttpPost
		body, err := ioutil.ReadAll(r.Body)
		if err != nil {
			log.Error(err)
		}
		// Unmarshal the POST into .Data
		err = json.Unmarshal(body, &newData.Data)
		// Type assert our way to the hostname
		newData.Host = newData.Data["host"].(map[string]interface{})["hostname"].(string)
		//newData.Time = string(time.Now().Format("2006010215040500"))
		respCh <- &newData
	}(r)

	// Check the channel for a resp
	select {
	case r := <-respCh:
		//	log.Debug("New data from ", r.Host, "@", r.Time)
		log.Debug("New data from ", r.Host)
		log.Debug(r.Data)
		hostDataArry = append(hostDataArry, r)
		dumpToElastic(hostDataArry)
	}

}
开发者ID:malnick,项目名称:cata-console,代码行数:35,代码来源:handlers.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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