packageelogimport("errors""github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context")typekeyintconstmetadataKeykey=0funcContextWithMetadata(ctxcontext.Context,lLoggable)context.Context{existing,err:=MetadataFromContext(ctx)iferr!=nil{// context does not contain meta. just set the new metadatachild:=context.WithValue(ctx,metadataKey,l.Loggable())returnchild}merged:=DeepMerge(existing,l.Loggable())child:=context.WithValue(ctx,metadataKey,merged)returnchild}funcMetadataFromContext(ctxcontext.Context)(Metadata,error){value:=ctx.Value(metadataKey)ifvalue!=nil{metadata,ok:=value.(Metadata)ifok{returnmetadata,nil}}returnnil,errors.New("context contains no metadata")}