private function setHande() { date_default_timezone_set("PRC"); self::$log = new Logger('name'); $rotating = new RotatingFileHandler($this->filepath, $this->log_keepDays, $this->log_level); $rotating->setFormatter($this->formatter); self::$log->pushHandler($rotating); }
/** * Factory method to create a new Amazon S3 client using an array of configuration options. * * @param array|Collection $config Client configuration data * * @return ObsClient * @link http://docs.aws.amazon.com/aws-sdk-php/guide/latest/configuration.html#client-configuration-options */ public static function factory($config = array()) { \S3Log::initLog(); $exceptionParser = new S3ExceptionParser(); // Configure the custom exponential backoff plugin for retrying S3 specific errors if (!isset($config[Options::BACKOFF])) { $config[Options::BACKOFF] = static::createBackoffPlugin($exceptionParser); } $config[Options::SIGNATURE] = $signature = static::createSignature($config); $client = ClientBuilder::factory(__NAMESPACE__)->setConfig($config)->setConfigDefaults(array(Options::VERSION => self::LATEST_API_VERSION, Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/s3-%s.php'))->setExceptionParser($exceptionParser)->setIteratorsConfig(array('more_key' => 'IsTruncated', 'operations' => array('ListBuckets', 'ListMultipartUploads' => array('limit_param' => 'MaxUploads', 'token_param' => array('KeyMarker', 'UploadIdMarker'), 'token_key' => array('NextKeyMarker', 'NextUploadIdMarker')), 'ListObjects' => array('limit_param' => 'MaxKeys', 'token_param' => 'Marker', 'token_key' => 'NextMarker'), 'ListVersions' => array('limit_param' => 'MaxKeys', 'token_param' => array('KeyMarker', 'VersionIdMarker'), 'token_key' => array('nextKeyMarker', 'nextVersionIdMarker')), 'ListParts' => array('limit_param' => 'MaxParts', 'result_key' => 'Parts', 'token_param' => 'PartNumberMarker', 'token_key' => 'NextPartNumberMarker'))))->build(); // Use virtual hosted buckets when possible $config[Options::PATH_STYLE] = isset($config[Options::PATH_STYLE]) ? $config[Options::PATH_STYLE] : true; $client->addSubscriber(new BucketStyleListener($config[Options::PATH_STYLE])); // Ensure that ACP headers are applied when needed $client->addSubscriber(new AcpListener()); // Validate and add required Content-MD5 hashes (e.g. DeleteObjects) $client->addSubscriber(new S3Md5Listener($signature)); // Allow for specifying bodies with file paths and file handles $client->addSubscriber(new UploadBodyListener(array('PutObject', 'UploadPart'))); // Ensures that if a SSE-CPK key is provided, the key and md5 are formatted correctly $client->addSubscriber(new SseCpkListener()); // Add aliases for some S3 operations $default = CompositeFactory::getDefaultChain($client); $default->add(new AliasFactory($client, static::$commandAliases), 'Guzzle\\Service\\Command\\Factory\\ServiceDescriptionFactory'); $client->setCommandFactory($default); self::$configArr = $config; return $client; }