// Log logs a log entry for a Cid. The ctx can contain an optional ffs.CtxKeyJid to add
// additional metadata about the log entry being part of a Job execution.
Log logs a log entry for a Cid. The ctx can contain an optional ffs.CtxKeyJid to add
additional metadata about the log entry being part of a Job execution.
// Log logs a log entry for a Cid . The ctx can contain an optional ffs . CtxKeyJid to add // additional metadata about the log entry being part of a Job execution .
func (cl *Logger) Log(ctx context.Context, format string, a ...interface{}) {
	log.Infof(format, a...)
	c, _ := ctx.Value(ffs.CtxStorageCid).(cid.Cid)
	rid, _ := ctx.Value(ffs.CtxRetrievalID).(ffs.RetrievalID)
	jid, _ := ctx.Value(ffs.CtxKeyJid).(ffs.JobID)
	iid, _ := ctx.Value(ffs.CtxAPIID).(ffs.APIID)
	now := time.Now()
	nowNano := now.UnixNano()
	key := makeKey(iid, c, rid, nowNano)
	le := logEntry{
		Cid:         c,
		RetrievalID: rid,
		Jid:         jid,
		Msg:         fmt.Sprintf(format, a...),
		Timestamp:   nowNano,
	}
	b, err := json.Marshal(le)
	if err != nil {
		log.Errorf("marshaling to json: %s", err)
		return
	}
	if err := cl.ds.Put(key, b); err != nil {
		log.Error("saving to datastore: %s", err)
		return
	}
	entry := ffs.LogEntry{
		APIID:     iid,
		Cid:       le.Cid,
		Jid:       le.Jid,
		Timestamp: now,
		Msg:       fmt.Sprintf(format, a...),
	}
	cl.lock.Lock()
	defer cl.lock.Unlock()
	for _, c := range cl.watchers {
		select {
		case c <- entry:
		default:
			log.Warn("slow cid log receiver")
		}
	}
}
func ( cl * Logger ) Log ( ctx context . Context , format string , a ... interface { } ) { log . Infof ( format , a ... ) c , _ := ctx . Value ( ffs . CtxStorageCid ) . ( cid . Cid ) rid , _ := ctx . Value ( ffs . CtxRetrievalID ) . ( ffs . RetrievalID ) jid , _ := ctx . Value ( ffs . CtxKeyJid ) . ( ffs . JobID ) iid , _ := ctx . Value ( ffs . CtxAPIID ) . ( ffs . APIID ) now := time . Now ( ) nowNano := now . UnixNano ( ) key := makeKey ( iid , c , rid , nowNano ) le := logEntry { Cid : c , RetrievalID : rid , Jid : jid , Msg : fmt . Sprintf ( format , a ... ) , Timestamp : nowNano , } b , err := json . Marshal ( le ) if err != nil { log . Errorf ( " " , err ) return } if err := cl . ds . Put ( key , b ) ; err != nil { log . Error ( " " , err ) return } entry := ffs . LogEntry { APIID : iid , Cid : le . Cid , Jid : le . Jid , Timestamp : now , Msg : fmt . Sprintf ( format , a ... ) , } cl . lock . Lock ( ) defer cl . lock . Unlock ( ) for _ , c := range cl . watchers { select { case c <- entry : default : log . Warn ( " " ) } } }
Log logs a log entry for a Cid.
Log logs a log entry for a Cid .
// Retrieve context values.