本文整理汇总了Golang中github.com/Sirupsen/logrus.Entry类的典型用法代码示例。如果您正苦于以下问题:Golang Entry类的具体用法?Golang Entry怎么用?Golang Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: searchByImdbID
// searchByImdbID searches on tmdb based on the imdb id
func (t *TmDB) searchByImdbID(m *polochon.Movie, log *logrus.Entry) error {
// No imdb id, no search
if m.ImdbID == "" {
return ErrNoMovieImDBID
}
// ID already found
if m.TmdbID != 0 {
return nil
}
// Search on tmdb
results, err := tmdbSearchByImdbID(t.client, m.ImdbID, "imdb_id", map[string]string{})
if err != nil {
return err
}
// Check if there is any results
if len(results.MovieResults) == 0 {
log.Debugf("Failed to find movie from imdb ID %q", m.ImdbID)
return ErrNoMovieFound
}
m.TmdbID = results.MovieResults[0].ID
log.Debugf("Found movie from imdb ID %q", m.ImdbID)
return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:30,代码来源:tmdb.go
示例2: DefaultBefore
// DefaultBefore is the default func assigned to *Middleware.Before
func DefaultBefore(entry *logrus.Entry, req *http.Request, remoteAddr string) *logrus.Entry {
return entry.WithFields(logrus.Fields{
"request": req.RequestURI,
"method": req.Method,
"remote": remoteAddr,
})
}
开发者ID:SpectoLabs,项目名称:hoverfly,代码行数:8,代码来源:middleware.go
示例3: Judge
/*
Judge run and judge other answers
*/
func Judge(dir, path string, answer []Answer, tests []os.FileInfo, timelimit float64, isConcurrent bool, logger *logrus.Entry) {
logger.WithFields(logrus.Fields{
"state": "check",
"type": "info",
"info": "check answers start"}).Info("Check answers start")
chk, err := chkSetup(dir, path, logger)
if err != nil {
return
}
//file setup
fileSetup(dir, tests, answer, isConcurrent, logger)
//testing
for k, s := range answer { //tests
id := k + 1
name := filepath.Base(s.Name)
outdir := filepath.Join(dir, "temp", fmt.Sprintf("ans_%d", id))
info := ProgInfo{Src: s.Name, Out: filepath.Join(outdir, fmt.Sprintf("ans_%d.out", id))}
test(outdir, name, id, info, tests, timelimit, chk, isConcurrent, logger)
}
logger.WithFields(logrus.Fields{
"state": "check",
"type": "info",
"info": "check answers end"}).Info("Check answers finished")
}
开发者ID:Camypaper,项目名称:libra,代码行数:31,代码来源:judge.go
示例4: 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
示例5: send
func (s *fileSender) send(entry *logrus.Entry) (err error) {
msg, err := entry.String()
if err != nil {
return
}
file, err := os.OpenFile(utils.GetLogPath(),
os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
err = &WriteError{
errors.Wrap(err, "logger: Failed to open log file"),
}
return
}
defer file.Close()
_, err = file.WriteString(msg)
if err != nil {
err = &WriteError{
errors.Wrap(err, "logger: Failed to write to log file"),
}
return
}
return
}
开发者ID:pathcode,项目名称:pritunl-client-electron,代码行数:26,代码来源:file.go
示例6: Stop
// Stop stops the app
func (b *Base) Stop(log *logrus.Entry) {
log.WithField("app", b.AppName).Debug("stopping app asynchronously")
if b.AppStatus == Started {
close(b.Done)
b.AppStatus = Stopped
}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:8,代码来源:base.go
示例7: Fire
func (h *StreamHook) Fire(entry *logrus.Entry) error {
h.Lock()
defer h.Unlock()
var line string
var err error
if line, err = entry.String(); err != nil {
if h.debug {
fmt.Fprintf(os.Stderr, "Unable to read entry: %v\n", err)
}
return err
}
if h.terminator != "" {
line += h.terminator
}
if _, err := h.writer.WriteString(line); err != nil {
if h.debug {
fmt.Fprintf(os.Stderr, "Unable to write the content: %v\n", err)
}
return err
}
if err := h.writer.Flush(); err != nil {
if h.debug {
fmt.Fprintf(os.Stderr, "Unable to flush the buffer: %v\n", err)
}
return err
}
return nil
}
开发者ID:xgfone,项目名称:go-rotating,代码行数:31,代码来源:stream.go
示例8: 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
示例9: Fire
// Fire fires the event to the ELK beat
func (elk *UDPHook) Fire(e *log.Entry) error {
// Make a copy to safely modify
entry := e.WithFields(nil)
if frameNo := findFrame(); frameNo != -1 {
t := newTrace(frameNo-1, nil)
entry.Data[FileField] = t.String()
entry.Data[FunctionField] = t.Func()
}
data, err := json.Marshal(Frame{
Time: elk.Clock.Now().UTC(),
Type: "trace",
Entry: entry.Data,
Message: entry.Message,
Level: entry.Level.String(),
})
if err != nil {
return Wrap(err)
}
c, err := net.ListenPacket("udp", ":0")
if err != nil {
return Wrap(err)
}
ra, err := net.ResolveUDPAddr("udp", "127.0.0.1:5000")
if err != nil {
return Wrap(err)
}
_, err = (c.(*net.UDPConn)).WriteToUDP(data, ra)
return Wrap(err)
}
开发者ID:gravitational,项目名称:trace,代码行数:34,代码来源:udphook.go
示例10: getLogrusLogger
// GetLogrusLogger returns the logrus logger for the context. If one more keys
// are provided, they will be resolved on the context and included in the
// logger. Only use this function if specific logrus functionality is
// required.
func getLogrusLogger(ctx Context, keys ...interface{}) *logrus.Entry {
var logger *logrus.Entry
// Get a logger, if it is present.
loggerInterface := ctx.Value("logger")
if loggerInterface != nil {
if lgr, ok := loggerInterface.(*logrus.Entry); ok {
logger = lgr
}
}
if logger == nil {
// If no logger is found, just return the standard logger.
logger = logrus.NewEntry(logrus.StandardLogger())
}
fields := logrus.Fields{}
for _, key := range keys {
v := ctx.Value(key)
if v != nil {
fields[fmt.Sprint(key)] = v
}
}
return logger.WithFields(fields)
}
开发者ID:useidel,项目名称:notary,代码行数:31,代码来源:logger.go
示例11: Fire
// Open the file, write to the file, close the file.
// Whichever user is running the function needs write permissions to the file or directory if the file does not yet exist.
func (hook *lfsHook) Fire(entry *logrus.Entry) error {
var (
fd *os.File
path string
msg string
err error
ok bool
)
if path, ok = hook.paths[entry.Level]; !ok {
err = fmt.Errorf("no file provided for loglevel: %d", entry.Level)
log.Println(err.Error())
return err
}
fd, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
log.Println("failed to open logfile:", path, err)
return err
}
defer fd.Close()
msg, err = entry.String()
if err != nil {
log.Println("failed to generate string for entry:", err)
return err
}
fd.WriteString(msg)
return nil
}
开发者ID:ahjdzx,项目名称:dis,代码行数:29,代码来源:lfshook.go
示例12: GetDetails
// GetDetails helps getting infos for a movie
// If there is an error, it will be of type *errors.Collector
func (m *Movie) GetDetails(log *logrus.Entry) error {
c := errors.NewCollector()
if len(m.Detailers) == 0 {
c.Push(errors.Wrap("No detailer available").Fatal())
return c
}
var done bool
for _, d := range m.Detailers {
detailerLog := log.WithField("detailer", d.Name())
err := d.GetDetails(m, detailerLog)
if err == nil {
done = true
break
}
c.Push(errors.Wrap(err).Ctx("Detailer", d.Name()))
}
if !done {
c.Push(errors.Wrap("All detailers failed").Fatal())
}
if c.HasErrors() {
return c
}
return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:30,代码来源:movie.go
示例13: search
func (k *Kickass) search(s Searcher, log *logrus.Entry) ([]polochon.Torrent, error) {
users := s.users()
result := []polochon.Torrent{}
log = log.WithFields(logrus.Fields{
"search_category": s.category(),
"search_string": s.searchStr(),
})
if err := s.validate(); err != nil {
log.Error(err)
return nil, err
}
for _, u := range users {
torrents, err := k.searchUser(s, log, u)
if err != nil {
return nil, err
}
result = append(result, torrents...)
}
return polochon.FilterTorrents(result), nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:25,代码来源:torrenter.go
示例14: GetSubtitle
// GetSubtitle implements the subtitle interface
// If there is an error, it will be of type *errors.Collector
func (m *Movie) GetSubtitle(log *logrus.Entry) error {
c := errors.NewCollector()
var subtitle Subtitle
for _, subtitler := range m.Subtitlers {
var err error
subtitlerLog := log.WithField("subtitler", subtitler.Name())
subtitle, err = subtitler.GetMovieSubtitle(m, subtitlerLog)
if err == nil {
break
}
c.Push(errors.Wrap(err).Ctx("Subtitler", subtitler.Name()))
}
if subtitle != nil {
file, err := os.Create(m.File.SubtitlePath())
if err != nil {
c.Push(errors.Wrap(err).Fatal())
return c
}
defer file.Close()
defer subtitle.Close()
if _, err := io.Copy(file, subtitle); err != nil {
c.Push(errors.Wrap(err).Fatal())
return c
}
}
if c.HasErrors() {
return c
}
return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:37,代码来源:movie.go
示例15: Watch
// Watch implements the modules fsNotifier interface
func (fs *FsNotify) Watch(watchPath string, ctx polochon.FsNotifierCtx, log *logrus.Entry) error {
// Create a new watcher
watcher, err := fsnotify.NewWatcher()
if err != nil {
return err
}
fs.watcher = watcher
// Ensure that the watch path exists
if _, err := os.Stat(watchPath); os.IsNotExist(err) {
return err
}
log = log.WithField("module", moduleName)
// Run the event handler
go fs.eventHandler(ctx, log)
// Watch the path
if err := fs.watcher.Add(watchPath); err != nil {
return err
}
return nil
}
开发者ID:odwrtw,项目名称:polochon,代码行数:26,代码来源:fsnotify.go
示例16: Fire
func (hook *SyslogHook) Fire(entry *logrus.Entry) error {
line, err := entry.String()
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err)
return err
}
switch entry.Level {
case logrus.PanicLevel:
return hook.Writer.Crit(line)
case logrus.FatalLevel:
return hook.Writer.Crit(line)
case logrus.ErrorLevel:
return hook.Writer.Err(line)
case logrus.WarnLevel:
return hook.Writer.Warning(line)
case logrus.InfoLevel:
return hook.Writer.Info(line)
case logrus.DebugLevel:
return hook.Writer.Debug(line)
case logrus.TraceLevel:
return hook.Writer.Debug(line)
default:
return nil
}
}
开发者ID:chendrak,项目名称:logrus,代码行数:26,代码来源:syslog.go
示例17: 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
示例18: getLogrusLogger
// GetLogrusLogger returns the logrus logger for the context. If one more keys
// are provided, they will be resolved on the context and included in the
// logger. Only use this function if specific logrus functionality is
// required.
func getLogrusLogger(ctx Context, keys ...interface{}) *logrus.Entry {
var logger *logrus.Entry
// Get a logger, if it is present.
loggerInterface := ctx.Value("logger")
if loggerInterface != nil {
if lgr, ok := loggerInterface.(*logrus.Entry); ok {
logger = lgr
}
}
if logger == nil {
fields := logrus.Fields{}
// Fill in the instance id, if we have it.
instanceID := ctx.Value("instance.id")
if instanceID != nil {
fields["instance.id"] = instanceID
}
fields["go.version"] = runtime.Version()
// If no logger is found, just return the standard logger.
logger = logrus.StandardLogger().WithFields(fields)
}
fields := logrus.Fields{}
for _, key := range keys {
v := ctx.Value(key)
if v != nil {
fields[fmt.Sprint(key)] = v
}
}
return logger.WithFields(fields)
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:39,代码来源:logger.go
示例19: Format
// Format formats a message from container
func (f *formatter) Format(entry *log.Entry) ([]byte, error) {
e := entry.WithFields(log.Fields{
"container": fmt.Sprintf("%.12s", f.containerID),
})
e.Message = entry.Message
e.Level = f.level
return f.delegate.Format(e)
}
开发者ID:romank87,项目名称:rocker,代码行数:9,代码来源:container_formatter.go
示例20: Notify
// Notify sends video to the notifiers
func (o *Organizer) Notify(v polochon.Video, log *logrus.Entry) {
log = log.WithField("function", "notify")
for _, n := range o.config.Notifiers {
if err := n.Notify(v, log); err != nil {
log.Warnf("failed to send a notification from notifier: %q: %q", n.Name(), err)
}
}
}
开发者ID:odwrtw,项目名称:polochon,代码行数:9,代码来源:organizer.go
注:本文中的github.com/Sirupsen/logrus.Entry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论