Skip to content

Commit

Permalink
pretty log message
Browse files Browse the repository at this point in the history
add timestamp to debug log message.
change timestamp format of access log.
  • Loading branch information
hirose31 committed Jun 28, 2009
1 parent 1794beb commit 73afe25
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/Doumeki/Log.pm
Expand Up @@ -4,6 +4,7 @@ use warnings;
use Log::Dispatch;
use Log::Dispatch::File;
use Log::Dispatch::Screen::Color;
use POSIX qw(strftime);

my($logger, $access_logger);

Expand Down Expand Up @@ -51,6 +52,7 @@ sub log {

my $msg = join(" ", @msg);
chomp $msg;
$msg = strftime("%Y-%m-%d %H:%M:%S", localtime)." $msg";

if ($logger) {
$logger->log( level => $alias{$level} || $level, message => "$msg\n" );
Expand All @@ -64,11 +66,12 @@ sub log_request {

$access_logger->log(
level => 'info',
message => sprintf qq(%s - %s [%s] "%s %s cmd=%s %s" %s %s "%s" "%s"\n),
$req->address, ($req->user || '-'), scalar localtime, $req->method,
$req->uri->path_query,
$req->param("g2_form[cmd]") || "-",
$req->protocol, $res->status, ($res->body ? bytes::length($res->body) : "-"),
message => sprintf qq(%s %s - %s "%s %s cmd=%s %s" %s %s "%s" "%s"\n),
strftime("%Y-%m-%d %H:%M:%S", localtime),
$req->address, ($req->user || '-'),
$req->method, $req->uri->path_query,
$req->param("g2_form[cmd]") || "-", $req->protocol,
$res->status, ($res->body ? bytes::length($res->body) : "-"),
($req->referer || '-'), ($req->user_agent || '-'),
);
}
Expand Down

0 comments on commit 73afe25

Please sign in to comment.