Created
May 24, 2012 01:11
-
-
Save anazawa/2778763 to your computer and use it in GitHub Desktop.
Apache 風のアクセス・ログを出力する Blosxom plugin
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
| package access_log; | |
| use strict; | |
| use warnings; | |
| use POSIX qw/strftime/; | |
| sub start { !$blosxom::static_entries } | |
| sub last { | |
| my $h = $ENV{REMOTE_ADDR}; | |
| my $l = '-'; | |
| my $u = '-'; | |
| my $t = strftime( "[%d/%b/%Y:%H:%M:%S %z]", localtime ); | |
| my $r = join ' ', @ENV{qw/REQUEST_METHOD REQUEST_URI SERVER_PROTOCOL/}; | |
| my $b = length $blosxom::output; | |
| my $status = $blosxom::header->{-status}; | |
| my $s = $status ? ( split / /, $status )[0] : '200'; | |
| my $referer = $ENV{HTTP_REFERER} || q{}; | |
| my $user_agent = $ENV{HTTP_USER_AGENT}; | |
| if ( open my $fh, '>>', "$blosxom::plugin_state_dir/access_log" ) { | |
| print $fh qq{$h $l $u $t "$r" $s $b "$referer" "$user_agent"\n}; | |
| close $fh; | |
| } | |
| } | |
| 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment