/** * Test for registerNamespace(). */ public function testRegisterNamespace() { $namespaces = ['ns_1']; $holder = new KeyBag(); $holder->registerNamespace($namespaces[0]); $this->assertEquals($namespaces, $holder->getNamespaces()); }
/** * Returns patters that can be replaced with as strings. * Note: This parser is not a validator, so in most cases patterns must not be exact * * @return array */ protected function getSimplePatterns() { // Register "request" namespace in KeyBag // This allows to convert parsed variables to array $this->keyBag->registerNamespace('request'); return ['%%' => '%', '%A' => '(?<local_ip>[\\dA-Za-z\\:\\.]{3,39})', '%a' => '(?<client_ip>[\\dA-Za-z\\:\\.]{3,39})', '%{c}a' => '(?<peer_ip>[\\dA-Za-z\\:\\.]{3,39})', '%B' => '(?<response_body_size>\\d+)', '%b' => '(?<response_body_size>\\d+|-)', '%D' => '(?<request_time_us>\\d+)', '%f' => '(?<filename>.+)', '%H' => '(?<request_protocol>\\S+)', '%h' => '(?<remote_host>\\S+)', '%I' => '(?<bytes_received>\\d+)', '%k' => '(?<keepalive_requests>\\d+)', '%L' => '(?<log_id>\\S+)', '%l' => '(?<identity>\\S+)', '%m' => '(?<request_method>[A-Za-z]+)', '%O' => '(?<bytes_sent>\\d+|\\-)', '%P' => '(?<process_id>\\S+)', '%p' => '(?<server_port>\\d+)', '%q' => '(?<query_string>\\?\\S+|)', '%R' => '(?<response_handler>\\S+)', '%r' => '(?<request_line>(?<request__method>\\w+) (?<request__path>\\S+)( (?<request__protocol>\\S+))?|-)', '%S' => '(?<bytes_transferred>\\d+)', '%s' => '(?<original_status_code>[2-5]\\d\\d)', '%>s' => '(?<response_code>[2-5]\\d\\d)', '%T' => '(?<request_time_s>\\d+)', '%t' => '\\[(?<time>\\d\\d\\/\\w{3}\\/\\d{4}\\:\\d\\d\\:\\d\\d\\:\\d\\d [+-]\\d{4})\\]', '%U' => '(?<request_path>\\S+?)', '%u' => '(?<remote_user>\\S+)', '%V' => '(?<server_name>\\S+)', '%v' => '(?<canonical_server_name>\\S+)', '%X' => '(?<connection_status>[Xx]|\\+|\\-)']; }