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


Golang logrus.Debug函数代码示例

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


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


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