public function putLogs(PutLogsRequest $request)
    {
        if (count($request->getLogItems()) > 4096) {
            throw new Exception("[InvalidLogSize] logItem's length exceeds maximum limitation: 4096 lines.");
        }

        $logGroup = new LogGroup ();
        $logGroup->setTopic($request->getTopic() ?: '');
        $source = $request->getSource();

        if ( ! $source) {
            $source = $this->source;
        }

        $logGroup->setSource($source);

        $logItems = $request->getLogItems();

        /**
         * @var LogItem $logItem
         */
        foreach ($logItems as $logItem) {

            $log = new Log();
            $log->setTime($logItem->getTime());
            $content = $logItem->getData();

            foreach ($content as $key => $value) {
                $content = new LogContent();
                $content->setKey($key);
                $content->setValue($value);
                $log->addContent($content);
            }

            $logGroup->addLogs($log);
        }

        $body = Util::toBytes($logGroup);

        unset ( $logGroup );

        $bodySize = strlen($body);

        if ($bodySize > 3 * 1024 * 1024) {
            throw new Exception("[InvalidLogSize] logItem's size exceeds maximum limitation: 3 MB.");
        }

        $params                         = array();
        $headers                        = array();
        $headers ["x-log-bodyrawsize"]  = $bodySize;
        $headers ['x-log-compresstype'] = 'deflate';
        $headers ['Content-Type']       = 'application/x-protobuf';
        $body                           = gzcompress($body, 6);

        $logStore = $request->getLogStore() ?: '';
        $project  = $request->getProject() ?: '';

        $resource = "/logstores/" . $logStore;

        list ( $resp, $header ) = $this->send("POST", $project, $body, $resource, $params, $headers);

        $requestId = isset ( $header['x-log-requestid'] ) ? $header['x-log-requestid'] : '';

        $this->parseToJson($resp, $requestId);

        return new PutLogsResponse($header);
    }
public function putLogs(PutLogsRequest $request)
    {
        if (count($request->getLogItems()) > 4096) {
            throw new Exception("[InvalidLogSize] logItem's length exceeds maximum limitation: 4096 lines.");
        }

        $logGroup = new LogGroup ();
        $logGroup->setTopic($request->getTopic() ?: '');
        $source = $request->getSource();

        if ( ! $source) {
            $source = $this->source;
        }

        $logGroup->setSource($source);

        $logItems = $request->getLogItems();

        /**
         * @var LogItem $logItem
         */
        foreach ($logItems as $logItem) {

            $log = new Log();
            $log->setTime($logItem->getTime());
            $content = $logItem->getData();

            foreach ($content as $key => $value) {
                $content = new LogContent();
                $content->setKey($key);
                $content->setValue($value);
                $log->addContent($content);
            }

            $logGroup->addLogs($log);
        }

        $body = Util::toBytes($logGroup);

        unset ( $logGroup );

        $bodySize = strlen($body);

        if ($bodySize > 3 * 1024 * 1024) {
            throw new Exception("[InvalidLogSize] logItem's size exceeds maximum limitation: 3 MB.");
        }

        $params                         = array();
        $headers                        = array();
        $headers ["x-log-bodyrawsize"]  = $bodySize;
        $headers ['x-log-compresstype'] = 'deflate';
        $headers ['Content-Type']       = 'application/x-protobuf';
        $body                           = gzcompress($body, 6);

        $logStore = $request->getLogStore() ?: '';
        $project  = $request->getProject() ?: '';

        $resource = "/logstores/" . $logStore;

        list ( $resp, $header ) = $this->send("POST", $project, $body, $resource, $params, $headers);

        $requestId = isset ( $header['x-log-requestid'] ) ? $header['x-log-requestid'] : '';

        $this->parseToJson($resp, $requestId);

        return new PutLogsResponse($header);
    }
public function putLogs ( PutLogsRequest $ request ) { if ( count ( $ request -> getLogItems ( ) ) > 4096 ) { throw new Exception ( "[InvalidLogSize] logItem's length exceeds maximum limitation: 4096 lines." ) ; } $ logGroup = new LogGroup ( ) ; $ logGroup -> setTopic ( $ request -> getTopic ( ) ? : '' ) ; $ source = $ request -> getSource ( ) ; if ( ! $ source ) { $ source = $ this -> source ; } $ logGroup -> setSource ( $ source ) ; $ logItems = $ request -> getLogItems ( ) ; /**
         * @var LogItem $logItem
         */ foreach ( $ logItems as $ logItem ) { $ log = new Log ( ) ; $ log -> setTime ( $ logItem -> getTime ( ) ) ; $ content = $ logItem -> getData ( ) ; foreach ( $ content as $ key => $ value ) { $ content = new LogContent ( ) ; $ content -> setKey ( $ key ) ; $ content -> setValue ( $ value ) ; $ log -> addContent ( $ content ) ; } $ logGroup -> addLogs ( $ log ) ; } $ body = Util :: toBytes ( $ logGroup ) ; unset ( $ logGroup ) ; $ bodySize = strlen ( $ body ) ; if ( $ bodySize > 3 * 1024 * 1024 ) { throw new Exception ( "[InvalidLogSize] logItem's size exceeds maximum limitation: 3 MB." ) ; } $ params = array ( ) ; $ headers = array ( ) ; $ headers [ "x-log-bodyrawsize" ] = $ bodySize ; $ headers [ 'x-log-compresstype' ] = 'deflate' ; $ headers [ 'Content-Type' ] = 'application/x-protobuf' ; $ body = gzcompress ( $ body , 6 ) ; $ logStore = $ request -> getLogStore ( ) ? : '' ; $ project = $ request -> getProject ( ) ? : '' ; $ resource = "/logstores/" . $ logStore ; list ( $ resp , $ header ) = $ this -> send ( "POST" , $ project , $ body , $ resource , $ params , $ headers ) ; $ requestId = isset ( $ header [ 'x-log-requestid' ] ) ? $ header [ 'x-log-requestid' ] : '' ; $ this -> parseToJson ( $ resp , $ requestId ) ; return new PutLogsResponse ( $ header ) ; }
Put logs to Log Service.
Unsuccessful operation will cause an Exception.

@param PutLogsRequest $request the PutLogs request parameters class

@throws Exception
@return PutLogsResponse
Put logs to Log Service . Unsuccessful operation will cause an Exception .