code: func (p *Plugin) Log(ctx context.Context, decision *server.Info) error {
  
  	path := strings.Replace(strings.TrimPrefix(decision.Path, "data."), ".", "/", -1)
  
  	event := EventV1{
  		Labels:      p.manager.Labels(),
  		DecisionID:  decision.DecisionID,
  		Revision:    decision.Revision,
  		Path:        path,
  		Query:       decision.Query,
  		Input:       decision.Input,
  		Result:      decision.Results,
  		RequestedBy: decision.RemoteAddr,
  		Timestamp:   decision.Timestamp,
  	}
  
  	if decision.Metrics != nil {
  		event.Metrics = decision.Metrics.All()
  	}
  
  	if decision.Error != nil {
  		event.Error = decision.Error
  	}
  
  	if p.config.Plugin != nil {
  		proxy, ok := p.manager.Plugin(*p.config.Plugin).(Logger)
  		if !ok {
  			return fmt.Errorf("plugin does not implement Logger interface")
  		}
  		return proxy.Log(ctx, event)
  	}
  
  	p.mtx.Lock()
  	defer p.mtx.Unlock()
  
  	result, err := p.enc.Write(event)
  	if err != nil {
  		// TODO(tsandall): revisit this now that we have an API that
  		// can return an error. Should the default behaviour be to
  		// fail-closed as we do for plugins?
  		p.logError("Log encoding failed: %v.", err)
  		return nil
  	}
  
  	if result != nil {
  		p.bufferChunk(p.buffer, result)
  	}
  
  	return nil
  }
docs: // Log appends a decision log event to the buffer for uploading.