Created
November 10, 2009 01:49
-
-
Save beppu/230547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use IO::File; | |
| use Plack::Builder; | |
| # | |
| # 1. Start the server like this: | |
| # plackup -a logger.psgi -e test -s Coro | |
| # | |
| # 2. Tail the access_log | |
| # touch access_log | |
| # tail -f access_log | |
| # | |
| # 3. Send requests to the server: | |
| # for i in `seq 1 5` ; do curl http://127.0.0.1:5000/$i ; done | |
| # | |
| # 4. Look at the access_log | |
| # | |
| # 0.0.0.0 [09/Nov/09:17:33:46 -0800] "GET /2 HTTP/1.1" "-" "-" | |
| # 0.0.0.0 [09/Nov/09:17:33:46 -0800] "GET /3 HTTP/1.1" "-" "-" | |
| # 0.0.0.0 [09/Nov/09:17:33:46 -0800] "GET /4 HTTP/1.1" "-" "-" | |
| # 0.0.0.0 [09/Nov/09:17:33:46 -0800] "GET /5 HTTP/1.1" "-" "-" | |
| # | |
| # 5. Ctrl-C the server. | |
| # | |
| # 0.0.0.0 [09/Nov/09:17:33:46 -0800] "GET /1 HTTP/1.1" "-" "-" | |
| # | |
| # | |
| # What am I doing wrong? | |
| # | |
| # create a filehandle for $env->{'psgi.errors'}; | |
| sub fh { | |
| IO::File->new(">> access_log"); | |
| } | |
| my $app = sub { | |
| my $env = shift; | |
| $env->{'psgi.errors'} = fh; | |
| [ 200, [ 'Content-Type' => 'text/html' ], [ "hi" ] ]; | |
| }; | |
| builder { | |
| enable "Plack::Middleware::AccessLog", | |
| format => '%h %{%d/%b/%y:%T %z}t "%r" "%{FEEDSTATUS}o" "%{FEEDINFO}o"'; | |
| $app; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment