func (h *Handler) Handle(e *log.Entry) {
	entry := LogEntry{
		Timestamp:   e.Timestamp.Format(time.RFC3339),
		TextPayload: e.Message,
		Fields:      e.Fields,
		Severity:    h.severity(e.Level),
	}

	if h.projectID != "" {
		if trace, ok := e.Fields["trace_id"]; ok {
			entry.Trace = fmt.Sprintf("projects/%s/traces/%v", h.projectID, trace)
		}
	}

	if span, ok := e.Fields["span_id"]; ok {
		entry.SpanID = fmt.Sprintf("%v", span)
	}

	if data, err := json.Marshal(&entry); err == nil {
		fmt.Fprintln(h.writer, string(data))
	}

	report := errorreporting.Entry{}

	if report.Error == nil {
		if message, ok := e.Fields["error_cause"]; ok {
			report.Error = fmt.Errorf("%v", message)
		}
	}

	if report.Error == nil {
		if message, ok := e.Fields["error_message"]; ok {
			report.Error = fmt.Errorf("%v", message)
		}
	}

	if stack, ok := e.Fields["error_stack"]; ok {
		report.Stack = []byte(
			fmt.Sprintf("%v", stack),
		)
	}

	if report.Error != nil {
		if err := h.reporter.ReportSync(context.TODO(), report); err != nil {
			fmt.Fprintln(h.writer, err.Error())
		}
	}
}
// Handle handles the log entry
Handle handles the log entry
// Handle handles the log entry
func (h *Handler) Handle(e *log.Entry) {
	entry := LogEntry{
		Timestamp:   e.Timestamp.Format(time.RFC3339),
		TextPayload: e.Message,
		Fields:      e.Fields,
		Severity:    h.severity(e.Level),
	}
	if h.projectID != "" {
		if trace, ok := e.Fields["trace_id"]; ok {
			entry.Trace = fmt.Sprintf("projects/%s/traces/%v", h.projectID, trace)
		}
	}
	if span, ok := e.Fields["span_id"]; ok {
		entry.SpanID = fmt.Sprintf("%v", span)
	}
	if data, err := json.Marshal(&entry); err == nil {
		fmt.Fprintln(h.writer, string(data))
	}
	report := errorreporting.Entry{}
	if report.Error == nil {
		if message, ok := e.Fields["error_cause"]; ok {
			report.Error = fmt.Errorf("%v", message)
		}
	}
	if report.Error == nil {
		if message, ok := e.Fields["error_message"]; ok {
			report.Error = fmt.Errorf("%v", message)
		}
	}
	if stack, ok := e.Fields["error_stack"]; ok {
		report.Stack = []byte(
			fmt.Sprintf("%v", stack),
		)
	}
	if report.Error != nil {
		if err := h.reporter.ReportSync(context.TODO(), report); err != nil {
			fmt.Fprintln(h.writer, err.Error())
		}
	}
}
func ( h * Handler ) Handle ( e * log . Entry ) { entry := LogEntry { Timestamp : e . Timestamp . Format ( time . RFC3339 ) , TextPayload : e . Message , Fields : e . Fields , Severity : h . severity ( e . Level ) , } if h . projectID != " " { if trace , ok := e . Fields [ " " ] ; ok { entry . Trace = fmt . Sprintf ( " " , h . projectID , trace ) } } if span , ok := e . Fields [ " " ] ; ok { entry . SpanID = fmt . Sprintf ( " " , span ) } if data , err := json . Marshal ( & entry ) ; err == nil { fmt . Fprintln ( h . writer , string ( data ) ) } report := errorreporting . Entry { } if report . Error == nil { if message , ok := e . Fields [ " " ] ; ok { report . Error = fmt . Errorf ( " " , message ) } } if report . Error == nil { if message , ok := e . Fields [ " " ] ; ok { report . Error = fmt . Errorf ( " " , message ) } } if stack , ok := e . Fields [ " " ] ; ok { report . Stack = [ ] byte ( fmt . Sprintf ( " " , stack ) , ) } if report . Error != nil { if err := h . reporter . ReportSync ( context . TODO ( ) , report ) ; err != nil { fmt . Fprintln ( h . writer , err . Error ( ) ) } } }
Handle handles the log entry
Handle handles the log entry