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


Golang logrus.Println函数代码示例

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


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

示例1: watch

func (c *consulCoordinator) watch(key string, cf consulFunc, stop chan struct{}) (chan interface{}, chan error) {
	new := make(chan interface{})
	errc := make(chan error)
	go func() {
		kv := c.client.KV()
		var lastIndex uint64
		for {
			select {
			case <-stop:
				return
			default:
				// do a blocking query
				ret, queryMeta, err := cf(kv, key, lastIndex)
				log.Println("[consul] value updated at", key, ret)
				if err != nil {
					log.Println(err)
					errc <- err
					return
				}
				if ret != nil {
					new <- ret
				}
				lastIndex = queryMeta.LastIndex
			}
		}
	}()
	return new, errc
}
开发者ID:nsaje,项目名称:dagger,代码行数:28,代码来源:consul.go

示例2: getPorts

func getPorts() ([]OsSerialPort, error) {
	resolver, err := bonjour.NewResolver(nil)
	if err != nil {
		log.Println("Failed to initialize resolver:", err.Error())
		return nil, err
	}

	results := make(chan *bonjour.ServiceEntry)

	timeout := make(chan bool, 1)
	go func(exitCh chan<- bool) {
		time.Sleep(timeoutConst * time.Second)
		exitCh <- true
		close(results)
	}(resolver.Exit)

	arrPorts := []OsSerialPort{}
	go func(results chan *bonjour.ServiceEntry, exitCh chan<- bool) {
		for e := range results {
			arrPorts = append(arrPorts, OsSerialPort{Name: e.AddrIPv4.String(), IdProduct: e.Instance, IdVendor: strings.Join(e.Text[:], " "), NetworkPort: true})
		}
		timeout <- true
	}(results, resolver.Exit)

	err = resolver.Browse("_arduino._tcp", "", results)
	if err != nil {
		log.Println("Failed to browse:", err.Error())
		return nil, err
	}
	// wait for some kind of timeout and return arrPorts
	select {
	case <-timeout:
		return arrPorts, nil
	}
}
开发者ID:matteosuppo,项目名称:arduino-create-agent,代码行数:35,代码来源:discovery.go

示例3: execCmd

// execCmd handles http requests received for the path "/exec"
func execCmd(w http.ResponseWriter, r *http.Request) {

	io.WriteString(w, "OK")

	go func() {
		cmd := r.URL.Query().Get("cmd")

		logrus.Info("got cmd: " + cmd)

		cmd, _ = url.QueryUnescape(cmd)
		arr := strings.Split(cmd, " ")

		logrus.Println("arr: ", arr)

		if len(arr) > 0 {
			cmd := exec.Command(arr[0], arr[1:]...)
			// Stdout buffer
			// cmdOutput := &bytes.Buffer{}
			// Attach buffer to command
			// cmd.Stdout = cmdOutput
			// Execute command
			// printCommand(cmd)
			err := cmd.Run() // will wait for command to return
			if err != nil {
				logrus.Println("Error:", err.Error())
			}
		}
	}()
}
开发者ID:stevesloka,项目名称:kubecraft,代码行数:30,代码来源:main.go

示例4: CreateSnapshot

func (d *driver) CreateSnapshot(
	runAsync bool,
	snapshotName, volumeID, description string) ([]*core.Snapshot, error) {

	resp, err := d.ec2Instance.CreateSnapshot(volumeID, description)
	if err != nil {
		return nil, err
	}

	if snapshotName != "" {
		_, err := d.ec2Instance.CreateTags(
			[]string{resp.Id}, []ec2.Tag{{"Name", snapshotName}})
		if err != nil {
			return nil, err
		}
	}

	if !runAsync {
		log.Println("Waiting for snapshot to complete")
		err = d.waitSnapshotComplete(resp.Snapshot.Id)
		if err != nil {
			return nil, err
		}
	}

	snapshot, err := d.GetSnapshot("", resp.Snapshot.Id, "")
	if err != nil {
		return nil, err
	}

	log.Println("Created Snapshot: " + snapshot[0].SnapshotID)
	return snapshot, nil

}
开发者ID:SebastianStadil,项目名称:rexray,代码行数:34,代码来源:ec2.go

示例5: initVars

func initVars() {

	done = make(chan int)

	resolvAddrs()

	password := flag.String("password", "0000", "Inverter password")
	groupType := flag.String("grouptype", "USER", "'USER' or 'INSTALLER'")
	server := flag.String("server", "tcp://notify.erkkila.org:1883", "The MQTT server to connect to")
	topic := flag.String("topic", "smapoller", "The chat room to enter. default 'smapoller'")
	name := flag.String("name", "pee", "Username to be displayed")

	flag.Parse()

	log.Println("SetP:", *password)
	log.Println("Gt:", *groupType)
	protocol.SetPassword(*password)
	protocol.SetGroupType(*groupType)
	protocol.SetAppSUSyID(AppSUSyID)
	protocol.SetAppSerial(getSerial())

	mqs = GetMQTTSettings()

	mqs.SetServer(server)
	mqs.SetTopic(topic)
	mqs.SetName(name)

}
开发者ID:pee,项目名称:smapoller,代码行数:28,代码来源:smapoller.go

示例6: writePacketLength

func writePacketLength(dst []byte) error {

	var LENGTH_OFFSET uint = 13
	var LENGTH_HEADER uint = 15
	var MAX_LENGTH uint = 0xFFFF

	if uint(len(dst)) < LENGTH_HEADER {
		log.Panic("Tried to set packet length to short buffer")
	}
	if uint(len(dst)) > MAX_LENGTH {
		log.Panic("Tried to set to big a packet length")
	}

	log.Println("Length of packet is:", len(dst))
	var length uint = uint(len(dst)) - (LENGTH_OFFSET + 7)
	log.Println("Setting packet length to:", length)

	l := make([]byte, 2)
	binary.LittleEndian.PutUint16(l, uint16(length))

	i := LENGTH_OFFSET
	dst[i] = l[0]
	i++
	dst[i] = l[1]

	return nil
}
开发者ID:pee,项目名称:smapoller,代码行数:27,代码来源:packetMaker.go

示例7: Delete

func (d *driver) Delete(volumeID api.VolumeID) error {
	v, err := d.GetVol(volumeID)
	if err != nil {
		logrus.Println(err)
		return err
	}

	bd, ok := d.buseDevices[v.DevicePath]
	if !ok {
		err = fmt.Errorf("Cannot locate a BUSE device for %s", v.DevicePath)
		logrus.Println(err)
		return err
	}

	// Clean up buse block file and close the NBD connection.
	os.Remove(bd.file)
	bd.f.Close()
	bd.nbd.Disconnect()

	logrus.Infof("BUSE deleted volume %v at NBD device %s", volumeID, v.DevicePath)

	err = d.DeleteVol(volumeID)
	if err != nil {
		logrus.Println(err)
		return err
	}

	return nil
}
开发者ID:pombredanne,项目名称:openstorage,代码行数:29,代码来源:buse.go

示例8: runWatcher

func runWatcher(address, datacenter, watchType string) {
	consulAlert := os.Args[0]
	cmd := exec.Command(
		"consul", "watch",
		"-http-addr", address,
		"-datacenter", datacenter,
		"-type", watchType,
		consulAlert, "watch", watchType)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	if err := cmd.Run(); err != nil {
		var exitCode int
		switch err.(type) {
		case *exec.ExitError:
			exitError, _ := err.(*exec.ExitError)
			status, _ := exitError.Sys().(syscall.WaitStatus)
			exitCode = status.ExitStatus()
			log.Println("Shutting down watcher --> Exit Code: ", exitCode)
		case *exec.Error:
			exitCode = 1
			log.Println("Shutting down watcher --> Something went wrong running consul watch: ", err.Error())
		default:
			exitCode = 127
			log.Println("Shutting down watcher --> Unknown error: ", err.Error())
		}
		os.Exit(exitCode)
	} else {
		log.Printf("Execution complete.")
	}
}
开发者ID:varunarya10,项目名称:consul-alerts,代码行数:31,代码来源:watchers.go

示例9: CmdList

func CmdList(databaseName string, page, pageSize int, id IDb, is services.IServices) error {
	service, err := is.RetrieveByLabel(databaseName)
	if err != nil {
		return err
	}
	if service == nil {
		return fmt.Errorf("Could not find a service with the label \"%s\". You can list services with the \"catalyze services\" command.", databaseName)
	}
	jobs, err := id.List(page, pageSize, service)
	if err != nil {
		return err
	}
	sort.Sort(SortedJobs(*jobs))
	for _, job := range *jobs {
		logrus.Printf("%s %s (status = %s)", job.ID, job.CreatedAt, job.Status)
	}
	if len(*jobs) == pageSize && page == 1 {
		logrus.Println("(for older backups, try with --page 2 or adjust --page-size)")
	}
	if len(*jobs) == 0 && page == 1 {
		logrus.Println("No backups created yet for this service.")
	} else if len(*jobs) == 0 {
		logrus.Println("No backups found with the given parameters.")
	}
	return nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:26,代码来源:list.go

示例10: CmdUpdate

func CmdUpdate(iu IUpdate) error {
	logrus.Println("Checking for available updates...")
	needsUpdate, err := iu.Check()
	if err != nil {
		return err
	}
	// check if we can overwrite exe
	if needsUpdate && (runtime.GOOS == "linux" || runtime.GOOS == "darwin") {
		err = verifyExeDirWriteable()
		if err != nil {
			return err
		}
	}
	if !needsUpdate {
		logrus.Println("You are already running the latest version of the Catalyze CLI")
		return nil
	}
	logrus.Printf("Version %s is available. Updating your CLI...", updater.AutoUpdater.Info.Version)
	err = iu.Update()
	if err != nil {
		return err
	}
	iu.UpdatePods()
	logrus.Printf("Your CLI has been updated to version %s", updater.AutoUpdater.Info.Version)
	return nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:26,代码来源:update.go

示例11: StartVotingRound

func (sn *Node) StartVotingRound(v *Vote) error {
	log.Println(sn.Name(), "start voting round")
	sn.nRounds = sn.LastSeenRound

	// during view changes, only accept view change related votes
	if sn.ChangingView && v.Vcv == nil {
		log.Println(sn.Name(), "start signing round: changingViewError")
		return ChangingViewError
	}

	sn.nRounds++
	v.Round = sn.nRounds
	v.Index = int(atomic.LoadInt64(&sn.LastSeenVote)) + 1
	v.Count = &Count{}
	v.Confirmed = false
	// only default fill-in view numbers when not prefilled
	if v.View == 0 {
		v.View = sn.ViewNo
	}
	if v.Av != nil && v.Av.View == 0 {
		v.Av.View = sn.ViewNo + 1
	}
	if v.Rv != nil && v.Rv.View == 0 {
		v.Rv.View = sn.ViewNo + 1
	}
	if v.Vcv != nil && v.Vcv.View == 0 {
		v.Vcv.View = sn.ViewNo + 1
	}
	return sn.StartAnnouncement(
		&AnnouncementMessage{LogTest: []byte("vote round"), Round: sn.nRounds, Vote: v})
}
开发者ID:ineiti,项目名称:prifi,代码行数:31,代码来源:signingNode.go

示例12: prepareQuery

func prepareQuery(topic *string, startTime *string, endTime *string, lastEvaluatedKey *map[string]*dynamodb.AttributeValue) *dynamodb.QueryInput {

	params := &dynamodb.QueryInput{
		TableName:         aws.String("midmessages"), // Required
		ConsistentRead:    aws.Bool(false),
		ExclusiveStartKey: prepareLastKey(lastEvaluatedKey),
		ExpressionAttributeNames: map[string]*string{
			"#ts": aws.String("timestamp"),
		},
		ExpressionAttributeValues: *prepareAttrValues(topic, startTime, endTime),
		//FilterExpression:       nil,
		//IndexName:              nil,
		KeyConditionExpression: prepareKeyCondition(topic, startTime, endTime),
		//KeyConditions: nil,
		//		Limit:                aws.Long(1),
		ProjectionExpression: aws.String("topic,#ts,sender,messageID,message,subject,notificationID"),
		//QueryFilter: nil,
		//		ReturnConsumedCapacity: aws.String("TOTAL"),
		ScanIndexForward: aws.Bool(true),
	}

	log.Println("endTime: ", *endTime)

	log.Println("prepareQuery:KeyConditionExpression: ", *params.KeyConditionExpression)

	return params
}
开发者ID:nbcnews,项目名称:midapi,代码行数:27,代码来源:Playback.go

示例13: Wait

func (e *AbstractExecutor) Wait() error {
	e.Build.BuildState = common.Running

	buildTimeout := e.Build.Timeout
	if buildTimeout <= 0 {
		buildTimeout = common.DefaultTimeout
	}

	// Wait for signals: cancel, timeout, abort or finish
	log.Debugln(e.Config.ShortDescription(), e.Build.ID, "Waiting for signals...")
	select {
	case <-e.BuildCanceled:
		log.Println(e.Config.ShortDescription(), e.Build.ID, "Build got canceled.")
		e.Build.FinishBuild(common.Failed, "Build got canceled")

	case <-time.After(time.Duration(buildTimeout) * time.Second):
		log.Println(e.Config.ShortDescription(), e.Build.ID, "Build timedout.")
		e.Build.FinishBuild(common.Failed, "CI Timeout. Execution took longer then %d seconds", buildTimeout)

	case signal := <-e.Build.BuildAbort:
		log.Println(e.Config.ShortDescription(), e.Build.ID, "Build got aborted", signal)
		e.Build.FinishBuild(common.Failed, "Build got aborted: %v", signal)

	case err := <-e.BuildFinish:
		if err != nil {
			return err
		}

		log.Println(e.Config.ShortDescription(), e.Build.ID, "Build succeeded.")
		e.Build.FinishBuild(common.Success, "Build succeeded.")
	}
	return nil
}
开发者ID:AdrianoJS,项目名称:gitlab-ci-multi-runner,代码行数:33,代码来源:executor_abstract.go

示例14: Start

func (c *consulCoordinator) Start(addr net.Addr, errCh chan error) error {
	if addr == nil {
		addr = &net.TCPAddr{}
	}
	c.addr = addr
	session := c.client.Session()
	// set session to delete our keys on invalidation
	sessionOptions := &api.SessionEntry{
		Behavior:  api.SessionBehaviorDelete,
		LockDelay: c.config.LockDelay,
		TTL:       c.config.TTL,
	}
	var sessionID string
	var err error
	err = backoff.RetryNotify(func() error {
		sessionID, _, err = session.Create(sessionOptions, nil)
		return err
	}, backoff.NewExponentialBackOff(), func(err error, t time.Duration) {
		log.Println("Cannot create session, retrying in", t, ". Error:", err)
	})
	if err != nil {
		return fmt.Errorf("failed to create consul session: %v", err)
	}

	// set up a long-running goroutine for renewing the session
	c.sessionRenew = make(chan struct{})
	c.sessionID = sessionID
	log.Println("[coordinator] Coordinator ready")

	go func() {
		errCh <- session.RenewPeriodic("5s", sessionID, nil, c.sessionRenew)
	}()
	return nil
}
开发者ID:nsaje,项目名称:dagger,代码行数:34,代码来源:consul.go

示例15: write

func write(wr writeRequest, id string) {
	cmds, idArr, bufTypeArr := createCommands(wr, id)

	qr := qReport{
		Cmd: "Queued",
		//Type: bufTypeArr,
		Ids:  idArr,
		D:    cmds,
		QCnt: wr.p.itemsInBuffer,
		Port: wr.p.portConf.Name,
	}
	json, _ := json.Marshal(qr)
	h.broadcastSys <- json

	// now send off the commands to the appropriate channel
	for index, cmdToSendToChannel := range cmds {
		//cmdIdCtr++
		//cmdId := "fakeid-" + strconv.Itoa(cmdIdCtr)
		cmdId := idArr[index]
		if bufTypeArr[index] == "Buf" {
			log.Println("Send was normal send, so sending to wr.p.sendBuffered")
			wr.p.sendBuffered <- Cmd{cmdToSendToChannel, cmdId, false, false}
		} else {
			log.Println("Send was sendnobuf, so sending to wr.p.sendNoBuf")
			wr.p.sendNoBuf <- Cmd{cmdToSendToChannel, cmdId, true, false}
		}
	}

	// garbage collect
	if *gcType == "max" {
		debug.FreeOSMemory()
	}

}
开发者ID:brunodisilva,项目名称:arduino-create-agent,代码行数:34,代码来源:serial.go


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