- improve logging format
authorMichael Wallner <mike@php.net>
Wed, 7 Sep 2005 16:58:30 +0000 (16:58 +0000)
committerMichael Wallner <mike@php.net>
Wed, 7 Sep 2005 16:58:30 +0000 (16:58 +0000)
- add logging tests

http_api.c
tests/allowed_methods_001.phpt
tests/allowed_methods_001_logging.phpt [new file with mode: 0644]
tests/redirect_001.phpt
tests/redirect_001_logging.phpt [new file with mode: 0644]
tests/redirect_002.phpt
tests/redirect_002_logging.phpt [new file with mode: 0644]
tests/redirect_003.phpt
tests/redirect_003_logging.phpt [new file with mode: 0644]
tests/send_data_007.phpt
tests/send_data_007_logging.phpt [new file with mode: 0644]

index cbc5a60d7d9adefdc21eb592c4bc0ff6e0f0eb72..8bbb34ac785fd6cd636b664628c15e99bf84ec4f 100644 (file)
@@ -198,7 +198,7 @@ void _http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC)
                php_stream *log = php_stream_open_wrapper(file, "ab", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); \
                 \
                if (log) { \
-                       php_stream_printf(log TSRMLS_CC, "%s [%12s] %32s <%s>%s", datetime, type, msg, SG(request_info).request_uri, PHP_EOL); \
+                       php_stream_printf(log TSRMLS_CC, "%s\t[%s]\t%s\t<%s>%s", datetime, type, msg, SG(request_info).request_uri, PHP_EOL); \
                        php_stream_close(log); \
                } \
         \
index 2f2c4e7bfc1ee7bb14343db728c0ebd9fb3aee55..f0b7d9c1b30af4a1606d4f35416eb850b9a3a0de 100644 (file)
@@ -7,6 +7,8 @@ checkcgi();
 ?>
 --FILE--
 <?php
+include 'log.inc';
+log_prepare(_AMETH_LOG);
 ini_set('http.allowed_methods', 'POST');
 echo "Done\n";
 ?>
diff --git a/tests/allowed_methods_001_logging.phpt b/tests/allowed_methods_001_logging.phpt
new file mode 100644 (file)
index 0000000..a9355aa
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+logging allowed methods
+--SKIPIF--
+include 'skip.inc';
+checkcgi();
+--ENV--
+HTTP_HOST=example.com
+--FILE--
+<?php
+echo "-TEST\n";
+include 'log.inc';
+log_content(_AMETH_LOG);
+echo "Done";
+?>
+--EXPECTF--
+%sTEST
+%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d      [405-ALLOWED]   Allow: POST     <%s>
+Done
index de6795f649e972470e30694f9dd86b38ea459a14..696157953300d39a62a5cafc558974d62671c385 100644 (file)
@@ -7,6 +7,8 @@ checkcgi();
 ?>
 --FILE--
 <?php
+include 'log.inc';
+log_prepare(_REDIR_LOG);
 http_redirect('redirect', array('a' => 1, 'b' => 2));
 ?>
 --EXPECTF--
diff --git a/tests/redirect_001_logging.phpt b/tests/redirect_001_logging.phpt
new file mode 100644 (file)
index 0000000..5237c1c
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+logging redirects
+--SKIPIF--
+include 'skip.inc';
+checkcgi();
+--ENV--
+HTTP_HOST=example.com
+--FILE--
+<?php
+echo "-TEST\n";
+include 'log.inc';
+log_content(_REDIR_LOG);
+echo "Done";
+?>
+--EXPECTF--
+%sTEST
+%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d      [302-REDIRECT]  Location: http%s        <%s>
+Done
index da77696ffe9155acdbd6bc67fdbb10a3c69ccd7f..9add4a0b1c3f0809b5967be69431bc881a9da0de 100644 (file)
@@ -7,6 +7,8 @@ checkcgi();
 ?>
 --FILE--
 <?php
+include 'log.inc';
+log_prepare(_REDIR_LOG);
 session_start();
 http_redirect('redirect', array('a' => 1), true);
 ?>
diff --git a/tests/redirect_002_logging.phpt b/tests/redirect_002_logging.phpt
new file mode 100644 (file)
index 0000000..5237c1c
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+logging redirects
+--SKIPIF--
+include 'skip.inc';
+checkcgi();
+--ENV--
+HTTP_HOST=example.com
+--FILE--
+<?php
+echo "-TEST\n";
+include 'log.inc';
+log_content(_REDIR_LOG);
+echo "Done";
+?>
+--EXPECTF--
+%sTEST
+%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d      [302-REDIRECT]  Location: http%s        <%s>
+Done
index 2f893c345384b709b9a878dd51a77c4cc7cd99e4..cd9fb4eff455305adf41e934eef0f96b9208ac96 100644 (file)
@@ -7,6 +7,8 @@ checkcgi();
 ?>
 --FILE--
 <?php
+include 'log.inc';
+log_prepare(_REDIR_LOG);
 http_redirect('redirect', null, false, true);
 ?>
 --EXPECTF--
diff --git a/tests/redirect_003_logging.phpt b/tests/redirect_003_logging.phpt
new file mode 100644 (file)
index 0000000..2296e63
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+logging redirects
+--SKIPIF--
+include 'skip.inc';
+checkcgi();
+--ENV--
+HTTP_HOST=example.com
+--FILE--
+<?php
+echo "-TEST\n";
+include 'log.inc';
+log_content(_REDIR_LOG);
+echo "Done";
+?>
+--EXPECTF--
+%sTEST
+%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d      [301-REDIRECT]  Location: http%s        <%s>
+Done
index f7b60f0806515676dca96ad77e5781d6727f7d89..f6d6058388b4735eb380f8bd223813b4107a2452 100644 (file)
@@ -9,6 +9,8 @@ checkcgi();
 HTTP_IF_NONE_MATCH="0bee89b07a248e27c83fc3d5951213c1"
 --FILE--
 <?php
+include 'log.inc';
+log_prepare(_CACHE_LOG);
 http_cache_etag();
 http_send_data("abc\n");
 ?>
diff --git a/tests/send_data_007_logging.phpt b/tests/send_data_007_logging.phpt
new file mode 100644 (file)
index 0000000..4395fca
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+logging caching
+--SKIPIF--
+include 'skip.inc';
+checkcgi();
+--ENV--
+HTTP_HOST=example.com
+--FILE--
+<?php
+echo "-TEST\n";
+include 'log.inc';
+log_content(_CACHE_LOG);
+echo "Done";
+?>
+--EXPECTF--
+%sTEST
+%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d      [304-CACHE]     ETag: "%s"      <%s>
+Done