// PutLogs put logs into logstore.
// The callers should transform user logs into LogGroup.

PutLogs put logs into logstore.
The callers should transform user logs into LogGroup.
// PutLogs put logs into logstore . // The callers should transform user logs into LogGroup .
func (s *LogStore) PutLogs(lg *LogGroup) (err error) {
	body, err := proto.Marshal(lg)
	if err != nil {
		return
	}
	out := make([]byte, lz4.CompressBound(body))
	n, err := lz4.Compress(body, out)
	if err != nil {
		return
	}
	h := map[string]string{
		"x-sls-compresstype": "lz4",
		"x-sls-bodyrawsize":  fmt.Sprintf("%v", len(body)),
		"Content-Type":       "application/x-protobuf",
	}
	uri := fmt.Sprintf("/logstores/%v", s.Name)
	r, err := request(s.project, "POST", uri, h, out[:n])
	if err != nil {
		return
	}
	buf, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return
	}
	if r.StatusCode != http.StatusOK {
		errMsg := &errorMessage{}
		err = json.Unmarshal(buf, errMsg)
		if err != nil {
			err = fmt.Errorf("failed to put logs")
			dump, _ := httputil.DumpResponse(r, true)
			fmt.Println(dump)
			return
		}
		err = fmt.Errorf("%v:%v", errMsg.Code, errMsg.Message)
		return
	}
	return
}
func ( s * LogStore ) PutLogs ( lg * LogGroup ) ( err error ) { body , err := proto . Marshal ( lg ) if err != nil { return } out := make ( [ ] byte , lz4 . CompressBound ( body ) ) n , err := lz4 . Compress ( body , out ) if err != nil { return } h := map [ string ] string { " " : " " , " " : fmt . Sprintf ( " " , len ( body ) ) , " " : " " , } uri := fmt . Sprintf ( " " , s . Name ) r , err := request ( s . project , " " , uri , h , out [ : n ] ) if err != nil { return } buf , err := ioutil . ReadAll ( r . Body ) if err != nil { return } if r . StatusCode != http . StatusOK { errMsg := & errorMessage { } err = json . Unmarshal ( buf , errMsg ) if err != nil { err = fmt . Errorf ( " " ) dump , _ := httputil . DumpResponse ( r , true ) fmt . Println ( dump ) return } err = fmt . Errorf ( " " , errMsg . Code , errMsg . Message ) return } return }
PutLogs put logs into logstore.
PutLogs put logs into logstore .
// Compresse body with lz4
