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


Golang Entry.Info方法代码示例

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


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

示例1: FindPackagesById

func FindPackagesById(c *gin.Context, d *FindPackagesByIdCommand, q *NuGetQuery, logger *log.Entry) {
	logger.Info("FindPackagesById")

	var match *rekt.Entry
	for _, pkg := range registry.Packages {
		if pkg.Title == d.Id && (q.Filter != "IsLatestVersion" || pkg.IsLatestVersion) {
			match = pkg
		}
	}

	feed := &rekt.Feed{
		Id:      "https://www.example.com/api/v2/FindPackagesById",
		Title:   "FindPackagesById",
		Updated: time.Now(),
		Entries: []*rekt.Entry{match},
	}

	atom, err := feed.ToAtom()
	if err != nil {
		c.Status(500)
		return
	}

	c.Data(200, AtomMimeType, atom)
	return
}
开发者ID:politician,项目名称:nugetd,代码行数:26,代码来源:main.go

示例2: checkRemoteHealthCheck

func (r RouteTableManagerEC2) checkRemoteHealthCheck(contextLogger *log.Entry, route *ec2.Route, rs ManageRoutesSpec) bool {
	contextLogger = contextLogger.WithFields(log.Fields{
		"remote_healthcheck": rs.RemoteHealthcheckName,
		"current_eni":        *(route.NetworkInterfaceId),
	})
	contextLogger.Info("Has remote healthcheck ")
	if ip, ok := eniToIP[*route.NetworkInterfaceId]; ok {
		contextLogger = contextLogger.WithFields(log.Fields{"current_ip": ip})
		if hc, ok := rs.remotehealthchecks[ip]; ok {
			contextLogger = contextLogger.WithFields(log.Fields{
				"healthcheck_healthy": hc.IsHealthy(),
				"healthcheck_ready":   hc.CanPassYet(),
			})
			contextLogger.Info("Has remote healthcheck instance")
			if hc.CanPassYet() {
				if hc.IsHealthy() {
					contextLogger.Debug("Not replacing route, as current route is healthy")
					return false
				} else {
					contextLogger.Debug("Replacing route as remote healthcheck is unhealthy")
				}
			} else {
				contextLogger.Debug("Not replacing route as remote healthcheck cannot pass yet")
				return false
			}
		} else {
			contextLogger.Error("Cannot find healthcheck")
			return false
		}
	} else {
		contextLogger.Error("Cannot find ip for ENI")
		return false
	}
	return true
}
开发者ID:tsheasha,项目名称:AWSnycast,代码行数:35,代码来源:route_table_manager.go

示例3: InfoForGood

func (a *Access) InfoForGood(entry *logrus.Entry, req *http.Request) {
	if host := RemoteHost(req); !a.Seen(host) {
		entry.Data["comment"] = fmt.Sprintf(
			";last info-logged successful request from %s", host)
		entry.Info("")
	} else {
		entry.Debug("")
	}
}
开发者ID:vadv,项目名称:ostent,代码行数:9,代码来源:logger.go

示例4: reclaimTask

func reclaimTask(client client.Queue, taskID string, runID int, log *logrus.Entry) (*queue.TaskReclaimResponse, *updateError) {
	log.Info("Reclaiming task")
	tcrsp, err := client.ReclaimTask(taskID, strconv.Itoa(runID))

	// check if an error occurred...
	if err != nil {
		return nil, &updateError{err: err.Error()}
	}

	log.Info("Reclaimed task successfully")
	return tcrsp, nil
}
开发者ID:taskcluster,项目名称:taskcluster-worker,代码行数:12,代码来源:taskstatusupdate.go

示例5: GetShowSubtitle

func (a *addictedProxy) GetShowSubtitle(reqEpisode *polochon.ShowEpisode, log *logrus.Entry) (polochon.Subtitle, error) {
	// TODO: add year
	// TODO: handle release

	shows, err := a.client.GetTvShows()
	if err != nil {
		return nil, err
	}
	var guessID string
	guessDist := 1000
	for showName, showID := range shows {
		dist := levenshtein.Distance(strings.ToLower(showName), strings.ToLower(reqEpisode.ShowTitle))
		if dist < guessDist {
			guessDist = dist
			guessID = showID
		}
	}

	subtitles, err := a.client.GetSubtitles(guessID, reqEpisode.Season, reqEpisode.Episode)
	if err != nil {
		return nil, err
	}

	filteredSubs := subtitles.FilterByLang(a.language)
	if len(filteredSubs) == 0 {
		return nil, polochon.ErrNoSubtitleFound
	}

	sort.Sort(addicted.ByDownloads(filteredSubs))

	if reqEpisode.ReleaseGroup == "" {
		log.Info("No release group specified get the most downloaded subtitle")
		return &filteredSubs[0], err
	}

	subDist := 1000
	var subtitle polochon.Subtitle
	var release string

	for _, sub := range filteredSubs {
		dist := levenshtein.Distance(strings.ToLower(reqEpisode.ReleaseGroup), strings.ToLower(sub.Release))
		if dist < subDist {
			subDist = dist
			subtitle = &sub
			release = sub.Release
		}
	}
	log.Info("Subtitle chosen ", release, " whit distance ", subDist)
	return subtitle, err
}
开发者ID:odwrtw,项目名称:polochon,代码行数:50,代码来源:addicted.go

示例6: claimTask

func claimTask(client client.Queue, taskID string, runID int, workerID string, workerGroup string, log *logrus.Entry) (*taskClaim, error) {
	log.Info("Claiming task")
	payload := queue.TaskClaimRequest{
		WorkerGroup: workerGroup,
		WorkerID:    workerID,
	}

	tcrsp, err := client.ClaimTask(taskID, strconv.Itoa(runID), &payload)
	// check if an error occurred...
	if err != nil {
		switch err := err.(type) {
		case httpbackoff.BadHttpResponseCode:
			e := &updateError{
				err:        err.Error(),
				statusCode: err.HttpResponseCode,
			}
			var errorMessage string
			switch {
			case err.HttpResponseCode == 401 || err.HttpResponseCode == 403:
				errorMessage = fmt.Sprintf("Not authorized to claim task %s (status code %v).", taskID, err.HttpResponseCode)
			case err.HttpResponseCode >= 500:
				errorMessage = fmt.Sprintf("Server error (status code %v) when attempting to claim task %v.", err.HttpResponseCode, taskID)
			case err.HttpResponseCode != 200:
				errorMessage = fmt.Sprintf("Received http status code %v when claiming task %v.", err.HttpResponseCode, taskID)
			}
			log.WithFields(logrus.Fields{
				"error":      err,
				"statusCode": err.HttpResponseCode,
			}).Error(errorMessage)
			return nil, e

		default:
			log.WithFields(logrus.Fields{
				"error": err,
			}).Error(fmt.Sprintf("Unexpected error occurred when claiming task %s", taskID))
			return nil, err
		}
	}

	return &taskClaim{
		taskID:     taskID,
		runID:      runID,
		taskClaim:  tcrsp,
		definition: &tcrsp.Task,
	}, nil
}
开发者ID:taskcluster,项目名称:taskcluster-worker,代码行数:46,代码来源:taskstatusupdate.go

示例7: Search

func Search(c *gin.Context, d *SearchCommand, q *NuGetQuery, logger *log.Entry) {
	logger.Info("Search")

	feed := &rekt.Feed{
		Id:      "https://www.example.com/api/v2/Search",
		Title:   "Search",
		Updated: time.Now(),
		Entries: registry.Packages, // just return all packages for every search
	}

	atom, err := feed.ToAtom()
	if err != nil {
		c.Status(500)
		return
	}

	c.Data(200, AtomMimeType, atom)
}
开发者ID:politician,项目名称:nugetd,代码行数:18,代码来源:main.go

示例8: Packages

func Packages(c *gin.Context, d *PackagesCommand, q *NuGetQuery, logger *log.Entry) {
	logger.Info("Packages")

	for _, pkg := range registry.Packages {
		if pkg.Title == d.Id && pkg.Version == d.Version {
			atom, err := pkg.ToAtom()
			if err != nil {
				c.Status(500)
				return
			}

			c.Data(200, AtomMimeType, atom)
			return
		}
	}

	c.Data(404, XmlMimeType, []byte(NuGetPackageNotFound))
}
开发者ID:politician,项目名称:nugetd,代码行数:18,代码来源:main.go

示例9: buildImage

func buildImage(
	log *logrus.Entry,
	inputFile, outputFile string,
	fromImage, novnc bool,
	boot,
	cdrom string,
	size int,
) error {
	// Find absolute outputFile
	outputFile, err := filepath.Abs(outputFile)
	if err != nil {
		log.Error("Failed to resolve output file, error: ", err)
		return err
	}

	// Create temp folder for the image
	tempFolder, err := ioutil.TempDir("", "taskcluster-worker-build-image-")
	if err != nil {
		log.Error("Failed to create temporary folder, error: ", err)
		return err
	}
	defer os.RemoveAll(tempFolder)

	var img *image.MutableImage
	if !fromImage {
		// Read machine definition
		machine, err2 := vm.LoadMachine(inputFile)
		if err2 != nil {
			log.Error("Failed to load machine file from ", inputFile, " error: ", err2)
			return err2
		}

		// Construct MutableImage
		log.Info("Creating MutableImage")
		img, err2 = image.NewMutableImage(tempFolder, int(size), machine)
		if err2 != nil {
			log.Error("Failed to create image, error: ", err2)
			return err2
		}
	} else {
		img, err = image.NewMutableImageFromFile(inputFile, tempFolder)
		if err != nil {
			log.Error("Failed to load image, error: ", err)
			return err
		}
	}

	// Create temp folder for sockets
	socketFolder, err := ioutil.TempDir("", "taskcluster-worker-sockets-")
	if err != nil {
		log.Error("Failed to create temporary folder, error: ", err)
		return err
	}
	defer os.RemoveAll(socketFolder)

	// Setup a user-space network
	log.Info("Creating user-space network")
	net, err := network.NewUserNetwork(tempFolder)
	if err != nil {
		log.Error("Failed to create user-space network, error: ", err)
		return err
	}

	// Setup logService so that logs can be posted to meta-service at:
	// http://169.254.169.254/v1/log
	net.SetHandler(&logService{Destination: os.Stdout})

	// Create virtual machine
	log.Info("Creating virtual machine")
	vm, err := vm.NewVirtualMachine(img.Machine().Options(), img, net, socketFolder, boot, cdrom, log.WithField("component", "vm"))
	if err != nil {
		log.Error("Failed to recreated virtual-machine, error: ", err)
		return err
	}

	// Start the virtual machine
	log.Info("Starting virtual machine")
	vm.Start()

	// Open VNC display
	if !novnc {
		go qemurun.StartVNCViewer(vm.VNCSocket(), vm.Done)
	}

	// Wait for interrupt to gracefully kill everything
	interrupted := make(chan os.Signal, 1)
	signal.Notify(interrupted, os.Interrupt)

	// Wait for virtual machine to be done, or we get interrupted
	select {
	case <-interrupted:
		vm.Kill()
		err = errors.New("SIGINT received, aborting virtual machine")
	case <-vm.Done:
		err = vm.Error
	}
	<-vm.Done
	signal.Stop(interrupted)
	defer img.Dispose()

//.........这里部分代码省略.........
开发者ID:taskcluster,项目名称:taskcluster-worker,代码行数:101,代码来源:buildimage.go

示例10: httpServer


//.........这里部分代码省略.........
		},
		{
			name:    "DeleteMovie",
			path:    "/movies/{id}",
			methods: "DELETE",
			handler: s.deleteMovie,
		},
		{
			name:     "DownloadMovie",
			path:     "/movies/{id}/download",
			methods:  "GET",
			handler:  s.serveMovie,
			excluded: !s.config.HTTPServer.ServeFiles,
		},
		{
			name:    "GetShows",
			path:    "/shows",
			methods: "GET",
			handler: s.showIds,
		},
		{
			name:    "GetShow",
			path:    "/shows/{id}",
			methods: "GET",
			handler: s.getShowDetails,
		},
		{
			name:    "GetSeason",
			path:    "/shows/{id}/seasons/{season:[0-9]+}",
			methods: "GET",
			handler: s.getSeasonDetails,
		},
		{
			name:    "GetEpisode",
			path:    "/shows/{id}/seasons/{season:[0-9]+}/episodes/{episode:[0-9]+}",
			methods: "GET",
			handler: s.getShowEpisodeIDDetails,
		},
		{
			name:    "DeleteEpisode",
			path:    "/shows/{id}/seasons/{season:[0-9]+}/episodes/{episode:[0-9]+}",
			methods: "DELETE",
			handler: s.deleteEpisode,
		},
		{
			name:     "DownloadEpisode",
			path:     "/shows/{id}/seasons/{season:[0-9]+}/episodes/{episode:[0-9]+}/download",
			methods:  "GET",
			handler:  s.serveShow,
			excluded: !s.config.HTTPServer.ServeFiles,
		},
		{
			name:    "Wishlist",
			path:    "/wishlist",
			methods: "GET",
			handler: s.wishlist,
		},
		{
			name:    "AddTorrent",
			path:    "/torrents",
			methods: "POST",
			handler: s.addTorrent,
		},
	} {
		if route.excluded {
			continue
		}

		// Register the route
		mux.HandleFunc(route.path, route.handler).Name(route.name).Methods(route.methods)
	}

	n := negroni.New()

	// Panic recovery
	n.Use(negroni.NewRecovery())

	// Use logrus as logger
	n.Use(negronilogrus.NewMiddlewareFromLogger(s.log.Logger, "httpServer"))

	// gzip compression
	n.Use(gzip.Gzip(gzip.DefaultCompression))

	// Add basic auth if configured
	if s.config.HTTPServer.BasicAuth {
		log.Info("server will require basic authentication")
		n.Use(NewBasicAuthMiddleware(s.config.HTTPServer.BasicAuthUser, s.config.HTTPServer.BasicAuthPassword))
	}

	// Add token auth middleware if token configuration file specified
	if s.tokenManager != nil {
		n.Use(token.NewMiddleware(s.tokenManager, mux))
		mux.HandleFunc("/tokens/allowed", s.tokenGetAllowed).Name("TokenGetAllowed")
	}

	// Wrap the router
	n.UseHandler(mux)

	return &http.Server{Addr: addr, Handler: n}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:101,代码来源:routes.go

示例11: handleApiEvents

func handleApiEvents(logContext *logrus.Entry, client string, events []*omaha.Event) error {
	for _, event := range events {
		evType, err := strconv.Atoi(event.Type)
		if err != nil {
			return err
		}

		evResult, err := strconv.Atoi(event.Result)
		if err != nil {
			return err
		}

		err = db.LogEvent(client, evType, evResult)
		if err != nil {
			logContext.Error(err)
		}
		switch evType {
		case eventTypeDownload:
			logContext.Info("Client is downloading new version.")
		case eventTypeArrive:
			logContext.Info("Client finished download.")
		case eventTypeApply:
			switch evResult {
			case eventResultOK:
				logContext.Info("Client applied package.")
			case eventResultError:
				logContext.Info("Client errored during update.")
			case eventResultDone:
				logContext.Info("Client upgraded to current version.")
			}
		case eventTypeSuccess:
			logContext.Info("Install success. Update completion prevented by instance.")
		default:
			logContext.Warn("Unknown event type %v.", evType)
		}
	}
	return nil
}
开发者ID:kdomanski,项目名称:comaha,代码行数:38,代码来源:api_handlers.go


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