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


Golang Entry.Debug方法代码示例

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


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

示例1: eventHandler

func (fs *FsNotify) eventHandler(ctx polochon.FsNotifierCtx, log *logrus.Entry) {
	// Notify the waitgroup
	ctx.Wg.Add(1)
	defer ctx.Wg.Done()

	// Close the watcher when done
	defer fs.watcher.Close()

	for {
		select {
		case <-ctx.Done:
			log.Debug("fsnotify is done watching")
			return
		case ev := <-fs.watcher.Events:
			if ev.Op != fsnotify.Create && ev.Op != fsnotify.Chmod {
				continue
			}

			// Wait for the delay time before sending an event.
			// Transmission creates the folder and move the files afterwards.
			// We need to wait for the file to be moved in before sending the
			// event. Delay is the estimated time to wait.
			go func() {
				time.Sleep(DELAY)
				ctx.Event <- ev.Name
			}()
		case err := <-fs.watcher.Errors:
			log.Error(err)
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:31,代码来源:fsnotify.go

示例2: Run

// Run runs the safeguard
func (s *Safeguard) Run(log *logrus.Entry) error {
	s.wg.Add(1)
	defer s.wg.Done()

	log = log.WithField("module", "safeguard")
	log.Debug("safeguard started")

	for {
		select {
		case <-s.done:
			log.Debug("safeguard stopped")
			return nil
		case <-s.event:
			// Increase the event count
			s.count++

			if s.count >= MaxEventCount {
				ctx := errors.Context{
					"current_count": s.count,
					"max_count":     MaxEventCount,
				}

				return errors.New("got %d safeguard events in less than %s",
					s.count, MaxEventDelay).Fatal().AddContext(ctx)
			}
		case <-time.After(MaxEventDelay):
			// Reset the panic count is there was not panic during the
			// MaxPanicDelay
			s.count = 0
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:33,代码来源:safeguard.go

示例3: cleanDoneVideos

func (c *Cleaner) cleanDoneVideos(log *logrus.Entry) {
	list, err := c.config.Downloader.Client.List()
	if err != nil {
		log.Errorf("error while getting torrent list: %q", err)
		return
	}

	for _, t := range list {
		torrentInfos := t.Infos()

		log = log.WithField("torrent_name", torrentInfos.Name)

		// Check if the file is ready to be cleaned
		isReady := c.isReadyToBeCleaned(t, log)
		if !isReady {
			log.Debug("torrent is not ready to be cleaned")
			continue
		}

		// We remove the torrent
		log.Debugf("removing torrent")
		err := c.config.Downloader.Client.Remove(t)
		if err != nil {
			log.Errorf("got error when removing torrent : %q", err)
			continue
		}

		log.Debug("removing files")
		if err = c.clean(t, log); err != nil {
			log.Errorf("failed to clean torrent files: %q", err)
			continue
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:34,代码来源:cleaner.go

示例4: downloadMissingMovies

func (d *Downloader) downloadMissingMovies(wl *polochon.Wishlist, log *logrus.Entry) {
	log = log.WithField("function", "download_movies")

	for _, wantedMovie := range wl.Movies {
		ok, err := d.library.HasMovie(wantedMovie.ImdbID)
		if err != nil {
			log.Error(err)
			continue
		}

		if ok {
			log.Debugf("movie %q already in the video store", wantedMovie.ImdbID)
			continue
		}

		m := polochon.NewMovie(d.config.Movie)
		m.ImdbID = wantedMovie.ImdbID
		log = log.WithField("imdb_id", m.ImdbID)

		if err := m.GetDetails(log); err != nil {
			errors.LogErrors(log, err)
			if errors.IsFatal(err) {
				continue
			}
		}

		log = log.WithField("title", m.Title)

		if err := m.GetTorrents(log); err != nil && err != polochon.ErrMovieTorrentNotFound {
			errors.LogErrors(log, err)
			if errors.IsFatal(err) {
				continue
			}
		}

		// Keep the torrent URL
		var torrentURL string
	quality_loop:
		for _, q := range wantedMovie.Qualities {
			for _, t := range m.Torrents {
				if t.Quality == q {
					torrentURL = t.URL
					break quality_loop
				}
			}
		}

		if torrentURL == "" {
			log.Debug("no torrent found")
			continue
		}

		if err := d.config.Downloader.Client.Download(torrentURL, log); err != nil {
			log.Error(err)
			continue
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:58,代码来源:downloader.go

示例5: handleConnection

func handleConnection(conn net.Conn, jobd *jobserver.JobServer, cbor *codec.CborHandle, reqLogger *logrus.Logger) {
	defer conn.Close()

	var reqLog, errLog *logrus.Entry
	fields := logrus.Fields{
		"remote": conn.RemoteAddr(),
	}
	errLog = logrus.WithFields(fields)
	if reqLogger != nil {
		reqLog = reqLogger.WithFields(fields)
	}

	jobdv := reflect.ValueOf(jobd)

	reader := bufio.NewReader(conn)
	decoder := codec.NewDecoder(reader, cbor)
	writer := bufio.NewWriter(conn)
	encoder := codec.NewEncoder(writer, cbor)

	for {
		var request cborrpc.Request
		err := decoder.Decode(&request)
		if err == io.EOF {
			if reqLog != nil {
				reqLog.Debug("Connection closed")
			}
			return
		} else if err != nil {
			errLog.WithError(err).Error("Error reading message")
			return
		}
		if reqLog != nil {
			reqLog.WithFields(logrus.Fields{
				"id":     request.ID,
				"method": request.Method,
			}).Debug("Request")
		}
		response := doRequest(jobdv, request)
		if reqLog != nil {
			entry := reqLog.WithField("id", response.ID)
			if response.Error != "" {
				entry = entry.WithField("error", response.Error)
			}
			entry.Debug("Response")
		}
		err = encoder.Encode(response)
		if err != nil {
			errLog.WithError(err).Error("Error encoding response")
			return
		}
		err = writer.Flush()
		if err != nil {
			errLog.WithError(err).Error("Error writing response")
			return
		}
	}
}
开发者ID:diffeo,项目名称:go-coordinate,代码行数:57,代码来源:cborrpc.go

示例6: 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

示例7: stopApps

// stopApps stops all the sub apps
func (a *App) stopApps(log *logrus.Entry) {
	log.Debug("stopping the sub apps")
	for _, subApp := range a.subApps {
		log.Debugf("stopping sub app %q", subApp.Name())
		subApp.Stop(log)
	}

	a.wg.Wait()
	log.Debug("sub apps stopped gracefully")
}
开发者ID:odwrtw,项目名称:polochon,代码行数:11,代码来源:app.go

示例8: NewResolver

func NewResolver(conn *tls.Conn, endpoint string, logger *logrus.Entry) (*Resolver, error) {
	certs := conn.ConnectionState().PeerCertificates
	chain := []ResolverPair{}

	for _, cert := range certs {
		cn := cert.Subject.CommonName
		if len(cert.Subject.OrganizationalUnit) > 0 && cn != "" {
			ou := cert.Subject.OrganizationalUnit[0]
			chain = append(chain, ResolverPair{cn, ou})
		}
	}

	if len(chain) == 0 {
		return nil, errors.New("Cannot found CommonName or OrganizationalUnit in peer certificate")
	}

	userId := chain[0].userId
	role := chain[0].role

	endpoint = strings.Replace(endpoint, ":userId", userId, 1)
	endpoint = strings.Replace(endpoint, ":role", role, 1)

	logger.Debug("Resolve using ", endpoint)

	response, err := http.Get(endpoint)
	if err != nil {
		return nil, err
	}

	defer response.Body.Close()

	content, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return nil, err
	}

	res := &Resolver{}

	err = json.Unmarshal(content, res)
	if err != nil {
		return nil, err
	}

	addrAndPort := strings.Join([]string{res.RawAddr, "2376"}, ":")

	addr, err := net.ResolveTCPAddr("tcp", addrAndPort)
	if err != nil {
		return nil, err
	}

	res.Addr = addr

	return res, nil
}
开发者ID:dmexe,项目名称:dd-app,代码行数:54,代码来源:resover.go

示例9: cleaner

func (c *Cleaner) cleaner(log *logrus.Entry) {
	for {
		select {
		case <-c.event:
			log.Debug("cleaner event")
			c.cleanDoneVideos(log)
		case <-c.Done:
			log.Debug("cleaner done handling events")
			return
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:12,代码来源:cleaner.go

示例10: downloader

func (d *Downloader) downloader(log *logrus.Entry) {
	for {
		select {
		case <-d.event:
			log.Debug("downloader event")
			d.downloadMissingVideos(log)
		case <-d.Done:
			log.Debug("downloader done handling events")
			return
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:12,代码来源:downloader.go

示例11: ticker

func (c *Cleaner) ticker(log *logrus.Entry) {
	tick := time.Tick(c.config.Downloader.Cleaner.Timer)
	for {
		select {
		case <-tick:
			log.Debug("cleaner timer triggered")
			c.event <- struct{}{}
		case <-c.Done:
			log.Debug("cleaner timer stopped")
			return
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:13,代码来源:cleaner.go

示例12: ticker

func (d *Downloader) ticker(log *logrus.Entry) {
	tick := time.Tick(d.config.Downloader.Timer)
	for {
		select {
		case <-tick:
			log.Debug("downloader timer triggered")
			d.event <- struct{}{}
		case <-d.Done:
			log.Debug("downloader timer stopped")
			return
		}
	}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:13,代码来源:downloader.go

示例13: startFsNotifier

// startFsNotifier starts the FsNotifier
func (o *Organizer) startFsNotifier(log *logrus.Entry) error {
	ctx := polochon.FsNotifierCtx{
		Event: o.event,
		Done:  o.Done,
		Wg:    &o.Wg,
	}

	// Send a notification to organize the whole folder on app start
	watcherPath := o.config.Watcher.Dir
	ctx.Event <- watcherPath

	// Launch the FsNotifier
	if err := o.config.Watcher.FsNotifier.Watch(watcherPath, ctx, log); err != nil {
		return err
	}

	var err error
	o.Wg.Add(1)
	go func() {
		defer func() {
			o.Wg.Done()
			if r := recover(); r != nil {
				err = errors.New("panic recovered").Fatal().AddContext(errors.Context{
					"sub_app": AppName,
				})
				o.Stop(log)
			}
		}()

		for {
			select {
			case file := <-ctx.Event:
				log.WithField("event", file).Debugf("got an event")
				if err := o.organize(file, log); err != nil {
					log.Errorf("failed to organize file: %q", err)
				}
			case <-o.Done:
				log.Debug("organizer done handling events")
				return
			}
		}
	}()

	o.Wg.Wait()

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

示例14: Run

// Run starts the downloader
func (o *Organizer) Run(log *logrus.Entry) error {
	// Create the channels
	o.event = make(chan string, 1)
	// Init the app
	o.InitStart(log)

	log = log.WithField("app", AppName)

	defer log.Debug("organizer stopped")

	// Start the file system notifier
	if err := o.startFsNotifier(log); err != nil {
		return err
	}

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

示例15: cleanDirectory

func (c *Cleaner) cleanDirectory(torrent *polochon.DownloadableInfos, log *logrus.Entry) error {
	if len(torrent.FilePaths) == 0 {
		return fmt.Errorf("no torrent files to clean")
	}

	// Get the path of one of the file to guess the directory that needs to be
	// deleted
	torrentFilePath := torrent.FilePaths[0]

	// Get the full path of the file
	filePath := filepath.Join(c.config.Watcher.Dir, torrentFilePath)
	// Get the directory of the file
	directoryPath := filepath.Dir(filePath)
	// Ensure the path is clean
	directoryPath = filepath.Clean(directoryPath)
	// We don't want to clean the DownloadDir
	if directoryPath == c.config.Downloader.DownloadDir {
		log.Debug("in the watching folder, no need to clean")
		return nil
	}

	// Get relative path of the directory to clean
	relDir, err := filepath.Rel(c.config.Downloader.DownloadDir, directoryPath)
	if err != nil {
		return err
	}

	// Get the first part of the directory to clean
	for filepath.Dir(relDir) != "." {
		relDir = filepath.Dir(relDir)
		log.Debugf("going higher : %s", relDir)
	}

	// Get the full path
	directoryToClean := filepath.Join(c.config.Downloader.DownloadDir, relDir)
	log.Debug("try to clean and delete")

	ok, err := IsEmpty(directoryToClean)
	if err != nil {
		log.Warnf("got error checking if directory is empty : %q", err)
		return err
	}
	if !ok {
		log.Debug("directory is not empty")
		return nil
	}

	log.Debug("everything is ready to delete the dir")

	// Delete the directory
	if err = c.deleteDirectory(directoryToClean, log); err != nil {
		return err
	}

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


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