func (sh *StackdriverHook) Fire(entry *logrus.Entry) error {
	sh.waitGroup.Add(1)
	go func(entry *logrus.Entry) {
		defer sh.waitGroup.Done()
		var httpReq *logging.HttpRequest

		// convert entry data to labels
		labels := make(map[string]string, len(entry.Data))
		for k, v := range entry.Data {
			switch x := v.(type) {
			case string:
				labels[k] = x

			case *http.Request:
				httpReq = &logging.HttpRequest{
					Referer:       x.Referer(),
					RemoteIp:      x.RemoteAddr,
					RequestMethod: x.Method,
					RequestUrl:    x.URL.String(),
					UserAgent:     x.UserAgent(),
				}

			case *logging.HttpRequest:
				httpReq = x

			default:
				labels[k] = fmt.Sprintf("%v", v)
			}
		}

		// write log entry
		if sh.agentClient != nil {
			sh.sendLogMessageViaAgent(entry, labels, httpReq)
		} else {
			sh.sendLogMessageViaAPI(entry, labels, httpReq)
		}
	}(sh.copyEntry(entry))

	return nil
}
func (sh *StackdriverHook) Fire(entry *logrus.Entry) error {
	sh.waitGroup.Add(1)
	go func(entry *logrus.Entry) {
		defer sh.waitGroup.Done()
		var httpReq *logging.HttpRequest

		
		labels := make(map[string]string, len(entry.Data))
		for k, v := range entry.Data {
			switch x := v.(type) {
			case string:
				labels[k] = x

			case *http.Request:
				httpReq = &logging.HttpRequest{
					Referer:       x.Referer(),
					RemoteIp:      x.RemoteAddr,
					RequestMethod: x.Method,
					RequestUrl:    x.URL.String(),
					UserAgent:     x.UserAgent(),
				}

			case *logging.HttpRequest:
				httpReq = x

			default:
				labels[k] = fmt.Sprintf("%v", v)
			}
		}

		
		if sh.agentClient != nil {
			sh.sendLogMessageViaAgent(entry, labels, httpReq)
		} else {
			sh.sendLogMessageViaAPI(entry, labels, httpReq)
		}
	}(sh.copyEntry(entry))

	return nil
}
func ( sh * StackdriverHook ) Fire ( entry * logrus . Entry ) error { sh . waitGroup . Add ( 1 ) go func ( entry * logrus . Entry ) { defer sh . waitGroup . Done ( ) var httpReq * logging . HttpRequest // convert entry data to labels labels := make ( map [ string ] string , len ( entry . Data ) ) for k , v := range entry . Data { switch x := v . ( type ) { case string : labels [ k ] = x case * http . Request : httpReq = & logging . HttpRequest { Referer : x . Referer ( ) , RemoteIp : x . RemoteAddr , RequestMethod : x . Method , RequestUrl : x . URL . String ( ) , UserAgent : x . UserAgent ( ) , } case * logging . HttpRequest : httpReq = x default : labels [ k ] = fmt . Sprintf ( " " , v ) } } // write log entry if sh . agentClient != nil { sh . sendLogMessageViaAgent ( entry , labels , httpReq ) } else { sh . sendLogMessageViaAPI ( entry , labels , httpReq ) } } ( sh . copyEntry ( entry ) ) return nil }
// Fire writes the message to the Stackdriver entry service.
Fire writes the message to the Stackdriver entry service .