func NewGinLogFormatter(Options ...func(*GinLog)) gin.LogFormatter {
	config := defaultGinLog

	for _, o := range Options {
		o(&config)
	}

	return func(params gin.LogFormatterParams) string {
		sLog := logging.LogEntry{
			HttpRequest: &ltype.HttpRequest{
				RequestMethod: params.Method,
				RequestUrl:    params.Request.URL.String(),
				Status:        int32(params.StatusCode),
				UserAgent:     params.Request.UserAgent(),
				RemoteIp:      params.ClientIP,
				Protocol:      params.Request.Proto,
				ResponseSize:  int64(params.BodySize),
			},
			Severity: config.Severity,
		}

		if !params.TimeStamp.IsZero() {
			ts, _ := ptypes.TimestampProto(params.TimeStamp)
			sLog.Timestamp = ts
		}

		if int64(params.Latency) != 0 {
			sLog.HttpRequest.Latency = ptypes.DurationProto(params.Latency)
		}

		m := &jsonpb.Marshaler{}
		result, err := m.MarshalToString(&sLog)

		if err != nil {
			return err.Error() + "\n"
		}

		return result + "\n"
	}
}
// NewGinLogFormatter takes zero or one GinOption function and applis to GinLog.
NewGinLogFormatter takes zero or one GinOption function and applis to GinLog.
// NewGinLogFormatter takes zero or one GinOption function and applis to GinLog .
func NewGinLogFormatter(Options ...func(*GinLog)) gin.LogFormatter {
	config := defaultGinLog
	for _, o := range Options {
		o(&config)
	}
	return func(params gin.LogFormatterParams) string {
		sLog := logging.LogEntry{
			HttpRequest: &ltype.HttpRequest{
				RequestMethod: params.Method,
				RequestUrl:    params.Request.URL.String(),
				Status:        int32(params.StatusCode),
				UserAgent:     params.Request.UserAgent(),
				RemoteIp:      params.ClientIP,
				Protocol:      params.Request.Proto,
				ResponseSize:  int64(params.BodySize),
			},
			Severity: config.Severity,
		}
		if !params.TimeStamp.IsZero() {
			ts, _ := ptypes.TimestampProto(params.TimeStamp)
			sLog.Timestamp = ts
		}
		if int64(params.Latency) != 0 {
			sLog.HttpRequest.Latency = ptypes.DurationProto(params.Latency)
		}
		m := &jsonpb.Marshaler{}
		result, err := m.MarshalToString(&sLog)
		if err != nil {
			return err.Error() + "\n"
		}
		return result + "\n"
	}
}
func NewGinLogFormatter ( Options ... func ( * GinLog ) ) gin . LogFormatter { config := defaultGinLog for _ , o := range Options { o ( & config ) } return func ( params gin . LogFormatterParams ) string { sLog := logging . LogEntry { HttpRequest : & ltype . HttpRequest { RequestMethod : params . Method , RequestUrl : params . Request . URL . String ( ) , Status : int32 ( params . StatusCode ) , UserAgent : params . Request . UserAgent ( ) , RemoteIp : params . ClientIP , Protocol : params . Request . Proto , ResponseSize : int64 ( params . BodySize ) , } , Severity : config . Severity , } if ! params . TimeStamp . IsZero ( ) { ts , _ := ptypes . TimestampProto ( params . TimeStamp ) sLog . Timestamp = ts } if int64 ( params . Latency ) != 0 { sLog . HttpRequest . Latency = ptypes . DurationProto ( params . Latency ) } m := & jsonpb . Marshaler { } result , err := m . MarshalToString ( & sLog ) if err != nil { return err . Error ( ) + " \n " } return result + " \n " } }
NewGinLogFormatter takes zero or one GinOption function and applis to GinLog.
NewGinLogFormatter takes zero or one GinOption function and applis to GinLog .