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


Golang Entry.Infof方法代码示例

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


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

示例1: RemoveSeason

// RemoveSeason removes the season from the index
func (si *ShowIndex) RemoveSeason(show *polochon.Show, season int, log *logrus.Entry) error {
	log.Infof("Deleting whole season %d of %s from index", season, show.ImdbID)

	delete(si.shows[show.ImdbID].Seasons, season)

	return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:8,代码来源:show_index.go

示例2: listMoviesByUser

func (k *Kickass) listMoviesByUser(movies map[string]*polochon.Movie, user string, log *logrus.Entry) error {
	query := &kickass.Query{
		User:     user,
		OrderBy:  "seeders",
		Order:    "desc",
		Category: string(MoviesCategory),
	}
	log = log.WithField("explore_user", user)

	torrents, err := k.client.ListByUser(query)
	if err != nil {
		return err
	}

	for _, t := range torrents {
		torrentStr := torrentGuessitStr(t)
		guess, err := guessit.Guess(torrentStr)
		if err != nil {
			continue
		}

		// Get the torrent quality
		torrentQuality := polochon.Quality(guess.Quality)
		if !torrentQuality.IsAllowed() {
			log.Infof("kickass: unhandled quality: %q", torrentQuality)
			continue
		}

		// Get the movie if its already in the map
		m, ok := movies[guess.Title]
		if !ok {
			// Create a new movie
			m = polochon.NewMovie(polochon.MovieConfig{})
			m.Title = guess.Title
			if guess.Year != 0 {
				m.Year = guess.Year
			}
		}

		log.WithFields(logrus.Fields{
			"torrent_quality": guess.Quality,
			"movie_title":     guess.Title,
		}).Debug("Adding torrent to the list")

		m.Torrents = append(m.Torrents, polochon.Torrent{
			Quality:    torrentQuality,
			URL:        t.MagnetURL,
			Seeders:    t.Seed,
			Leechers:   t.Leech,
			Source:     moduleName,
			UploadUser: user,
		})

		movies[m.Title] = m
	}

	return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:58,代码来源:explorer.go

示例3: searchUser

func (k *Kickass) searchUser(s Searcher, log *logrus.Entry, user string) ([]polochon.Torrent, error) {
	query := &kickass.Query{
		User:     user,
		OrderBy:  "seeders",
		Order:    "desc",
		Category: string(s.category()),
		Search:   s.searchStr(),
	}
	log = log.WithField("search_user", user)

	torrents, err := k.client.Search(query)
	if err != nil {
		return nil, err
	}

	result := []polochon.Torrent{}
	for _, t := range torrents {
		torrentStr := torrentGuessitStr(t)
		guess, err := guessit.Guess(torrentStr)
		if err != nil {
			continue
		}

		if !s.isValidGuess(guess, log) {
			continue
		}

		// Default quality
		if s.category() == ShowsCategory && guess.Quality == "" {
			guess.Quality = string(polochon.Quality480p)
		}

		// Get the torrent quality
		torrentQuality := polochon.Quality(guess.Quality)
		if !torrentQuality.IsAllowed() {
			log.Infof("kickass: unhandled quality: %q", torrentQuality)
			continue
		}

		log.WithFields(logrus.Fields{
			"torrent_quality": guess.Quality,
			"torrent_name":    torrentStr,
		}).Debug("Adding torrent to the list")

		// Add the torrent
		result = append(result, polochon.Torrent{
			Quality:    torrentQuality,
			URL:        t.MagnetURL,
			Seeders:    t.Seed,
			Leechers:   t.Leech,
			Source:     moduleName,
			UploadUser: user,
		})
	}

	return result, nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:57,代码来源:torrenter.go

示例4: isValidGuess

func (ms *MovieSearcher) isValidGuess(guess *guessit.Response, log *logrus.Entry) bool {
	// Check if the years match
	if ms.Year != 0 && guess.Year != 0 && guess.Year != ms.Year {
		log.Infof("invalid year: guessed (%d) wanted (%d)", guess.Year, ms.Year)
		return false
	}

	return true
}
开发者ID:odwrtw,项目名称:polochon,代码行数:9,代码来源:movies.go

示例5: RemoveShow

// RemoveShow removes the show from the index
func (si *ShowIndex) RemoveShow(show *polochon.Show, log *logrus.Entry) error {
	log.Infof("Deleting whole show %s from index", show.ImdbID)

	si.Lock()
	defer si.Unlock()
	delete(si.shows, show.ImdbID)

	return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:10,代码来源:show_index.go

示例6: isValidGuess

func (se *ShowEpisodeSearcher) isValidGuess(guess *guessit.Response, log *logrus.Entry) bool {
	// Check if the years match
	if guess.Season == 0 || guess.Episode == 0 {
		log.Infof("no season or episode guessed from title")
		return false
	}

	// Check if the years match
	if guess.Season != se.Season || guess.Episode != se.Episode {
		log.Infof("episode do not match: guessed S%02dE%02d, wanted S%02dE%02d", guess.Season, guess.Episode, se.Season, se.Episode)
		return false
	}

	return true
}
开发者ID:odwrtw,项目名称:polochon,代码行数:15,代码来源:shows.go

示例7: DeleteMovie

// DeleteMovie will delete the movie
func (l *Library) DeleteMovie(m *polochon.Movie, log *logrus.Entry) error {
	// Delete the movie
	d := filepath.Dir(m.Path)
	log.Infof("Removing Movie %s", d)

	if err := os.RemoveAll(d); err != nil {
		return err
	}
	// Remove the movie from the index
	if err := l.movieIndex.Remove(m, log); err != nil {
		return err
	}

	return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:16,代码来源:library.go

示例8: buildMovieIndex

func (l *Library) buildMovieIndex(log *logrus.Entry) error {
	start := time.Now()
	err := filepath.Walk(l.MovieDir, func(filePath string, file os.FileInfo, err error) error {
		// Check err
		if err != nil {
			log.Errorf("library: failed to walk %q", err)
			return nil
		}

		// Nothing to do on dir
		if file.IsDir() {
			return nil
		}

		// search for movie type
		ext := path.Ext(filePath)

		var moviePath string
		for _, mext := range l.fileConfig.VideoExtentions {
			if ext == mext {
				moviePath = filePath
				break
			}
		}

		if moviePath == "" {
			return nil
		}

		// Read the movie informations
		movie, err := l.newMovieFromPath(moviePath)
		if err != nil {
			log.Errorf("library: failed to read movie NFO: %q", err)
			return nil
		}

		// Add the movie to the index
		l.movieIndex.Add(movie)

		return nil
	})

	log.Infof("Index built in %s", time.Since(start))

	return err
}
开发者ID:odwrtw,项目名称:polochon,代码行数:46,代码来源:library.go

示例9: buildShowIndex

func (l *Library) buildShowIndex(log *logrus.Entry) error {
	start := time.Now()

	// used to catch if the first root folder has been walked
	var rootWalked bool
	// Get only the parent folders
	err := filepath.Walk(l.ShowDir, func(filePath string, file os.FileInfo, err error) error {
		// Only check directories
		if !file.IsDir() {
			return nil
		}

		// The root folder is only walk once
		if !rootWalked {
			rootWalked = true
			return nil
		}

		// Check if we can find the tvshow.nfo file
		nfoPath := l.showNFOPath(filePath)
		show, err := l.newShowFromPath(nfoPath)
		if err != nil {
			log.Errorf("library: failed to read tv show NFO: %q", err)
			return nil
		}

		// Scan the path for the episodes
		err = l.scanEpisodes(show.ImdbID, filePath, log)
		if err != nil {
			return err
		}

		// No need to go deeper, the tvshow.nfo is in the second root folder
		return filepath.SkipDir
	})
	if err != nil {
		return err
	}

	log.Infof("Index built in %s", time.Since(start))

	return nil

}
开发者ID:odwrtw,项目名称:polochon,代码行数:44,代码来源:library.go

示例10: SetupBolt

// SetupBolt opens a boltdb and creates a meta bucket if not exists.
func SetupBolt(path string, l *logrus.Entry) error {
	l.Infof("Open boltDB: %s", path)
	db, err := bolt.Open(path, 0600, nil)
	if err != nil {
		return err
	}

	b := Bolt{
		Path: path,
		Log:  l,
		db:   db,
	}
	if err = b.createBucketIfNotExists(metabucket); err != nil {
		return err
	}

	DB = b
	return nil
}
开发者ID:ymomoi,项目名称:vuls,代码行数:20,代码来源:bolt.go

示例11: NewListenLogger

func NewListenLogger(logger *logrus.Entry, p *project.Project) chan<- project.Event {
	listenChan := make(chan project.Event)
	go func() {
		for event := range listenChan {
			buffer := bytes.NewBuffer(nil)
			if event.Data != nil {
				for k, v := range event.Data {
					if buffer.Len() > 0 {
						buffer.WriteString(", ")
					}
					buffer.WriteString(k)
					buffer.WriteString("=")
					buffer.WriteString(v)
				}
			}

			logger.Infof("[%s:%s]: %s %s", p.Name, event.ServiceName, event.EventType, buffer.Bytes())
		}
	}()
	return listenChan
}
开发者ID:alena1108,项目名称:rancher-compose-executor,代码行数:21,代码来源:log.go

示例12: handleApiUpdateCheck

// parse an 'UpdateCheck' tag of request and generate a corresponding 'UpdateCheck' tag of response
func handleApiUpdateCheck(logContext *logrus.Entry, localUrl string, appVersion payloadVersion, channel string, ucRequest, ucResp *omaha.UpdateCheck) {
	payload, err := db.GetNewerPayload(appVersion, channel)
	if err != nil {
		logContext.Errorf("Failed checking for newer payload: %v", err.Error())
		ucResp.Status = "error-internal"
	} else {
		if payload == nil {
			logContext.Infof("Client already up-to-date")
			ucResp.Status = "noupdate"
			return
		}

		logContext.Infof("Found update to version '%v' (id %v)", payload.Version, payload.ID)

		ucResp.Status = "ok"
		ucResp.AddUrl(fileBE.GetUpdateURL(localUrl))

		manifest := ucResp.AddManifest("1.0.2")
		manifest.AddPackage(payload.SHA1, payload.ID, strconv.FormatInt(payload.Size, 10), true)
		action := manifest.AddAction("postinstall")
		action.Sha256 = payload.SHA256
		action.DisablePayloadBackoff = true
	}
}
开发者ID:kdomanski,项目名称:comaha,代码行数:25,代码来源:api_handlers.go

示例13: DeleteShowEpisode

// DeleteShowEpisode will delete the showEpisode
func (l *Library) DeleteShowEpisode(se *polochon.ShowEpisode, log *logrus.Entry) error {
	// Delete the episode
	log.Infof("Removing ShowEpisode %q", se.Path)
	// Remove the episode
	if err := os.RemoveAll(se.Path); err != nil {
		return err
	}
	pathWithoutExt := se.PathWithoutExt()
	// Remove also the .nfo and .srt files
	for _, ext := range []string{"nfo", "srt"} {
		fileToDelete := fmt.Sprintf("%s.%s", pathWithoutExt, ext)
		log.Debugf("Removing %q", fileToDelete)
		// Remove file
		if err := os.RemoveAll(fileToDelete); err != nil {
			return err
		}
	}

	// Remove the episode from the index
	if err := l.showIndex.RemoveEpisode(se, log); err != nil {
		return err
	}

	// Season is empty, delete the whole season
	ok, err := l.showIndex.IsSeasonEmpty(se.ShowImdbID, se.Season)
	if err != nil {
		return err
	}
	if ok {
		// Delete the whole season
		seasonDir := l.getSeasonDir(se)
		if err := os.RemoveAll(seasonDir); err != nil {
			return err
		}
		// Remove the season from the index
		show := &polochon.Show{ImdbID: se.ShowImdbID}
		if err := l.showIndex.RemoveSeason(show, se.Season, log); err != nil {
			return err
		}
	}

	// Show is empty, delete the whole show from the index
	ok, err = l.showIndex.IsShowEmpty(se.ShowImdbID)
	if err != nil {
		return err
	}
	if ok {
		// Delete the whole Show
		showDir := l.getShowDir(se)
		if err := os.RemoveAll(showDir); err != nil {
			return err
		}
		// Remove the show from the index
		show := &polochon.Show{ImdbID: se.ShowImdbID}
		if err := l.showIndex.RemoveShow(show, log); err != nil {
			return err
		}
	}

	return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:62,代码来源:library.go


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