logging: Move colon from the label to logmsg
This commit is contained in:
parent
3262dd0952
commit
23bc8cdac3
2 changed files with 13 additions and 13 deletions
14
ddclient.in
14
ddclient.in
|
@ -2358,7 +2358,7 @@ sub logmsg {
|
||||||
chomp($buffer);
|
chomp($buffer);
|
||||||
|
|
||||||
my $prefix = $args{label};
|
my $prefix = $args{label};
|
||||||
$prefix = sprintf "%-8s ", $prefix if $prefix;
|
$prefix = sprintf("%-8s ", $prefix . ':') if $prefix;
|
||||||
if ($file) {
|
if ($file) {
|
||||||
$prefix .= "file $file";
|
$prefix .= "file $file";
|
||||||
$prefix .= ", line $lineno" if $lineno;
|
$prefix .= ", line $lineno" if $lineno;
|
||||||
|
@ -2383,12 +2383,12 @@ sub logmsg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sub _logmsg_fmt { return (@_ > 1) ? sprintf(shift, @_) : shift; }
|
sub _logmsg_fmt { return (@_ > 1) ? sprintf(shift, @_) : shift; }
|
||||||
sub info { logmsg(email => 1, label => 'INFO:', _logmsg_fmt(@_)) if opt('verbose'); }
|
sub info { logmsg(email => 1, label => 'INFO', _logmsg_fmt(@_)) if opt('verbose'); }
|
||||||
sub debug { logmsg( label => 'DEBUG:', _logmsg_fmt(@_)) if opt('debug'); }
|
sub debug { logmsg( label => 'DEBUG', _logmsg_fmt(@_)) if opt('debug'); }
|
||||||
sub warning { logmsg(email => 1, label => 'WARNING:', _logmsg_fmt(@_)); }
|
sub warning { logmsg(email => 1, label => 'WARNING', _logmsg_fmt(@_)); }
|
||||||
sub fatal { logmsg(email => 1, label => 'FATAL:', _logmsg_fmt(@_)); sendmail(); exit(1); }
|
sub fatal { logmsg(email => 1, label => 'FATAL', _logmsg_fmt(@_)); sendmail(); exit(1); }
|
||||||
sub success { logmsg(email => 1, label => 'SUCCESS:', _logmsg_fmt(@_)); }
|
sub success { logmsg(email => 1, label => 'SUCCESS', _logmsg_fmt(@_)); }
|
||||||
sub failed { logmsg(email => 1, label => 'FAILED:', _logmsg_fmt(@_)); $result = 'FAILED'; }
|
sub failed { logmsg(email => 1, label => 'FAILED', _logmsg_fmt(@_)); $result = 'FAILED'; }
|
||||||
|
|
||||||
sub prettytime { return scalar(localtime(shift)); }
|
sub prettytime { return scalar(localtime(shift)); }
|
||||||
|
|
||||||
|
|
12
t/logmsg.pl
12
t/logmsg.pl
|
@ -54,22 +54,22 @@ my @test_cases = (
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc => 'single-line label',
|
desc => 'single-line label',
|
||||||
args => [label => 'LBL:', 'foo'],
|
args => [label => 'LBL', 'foo'],
|
||||||
want => "LBL: > foo\n",
|
want => "LBL: > foo\n",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc => 'multi-line label',
|
desc => 'multi-line label',
|
||||||
args => [label => 'LBL:', "foo\nbar"],
|
args => [label => 'LBL', "foo\nbar"],
|
||||||
want => "LBL: > foo\nLBL: bar\n",
|
want => "LBL: > foo\nLBL: bar\n",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc => 'single-line long label',
|
desc => 'single-line long label',
|
||||||
args => [label => 'VERY LONG LABEL:', 'foo'],
|
args => [label => 'VERY LONG LABEL', 'foo'],
|
||||||
want => "VERY LONG LABEL: > foo\n",
|
want => "VERY LONG LABEL: > foo\n",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc => 'multi-line long label',
|
desc => 'multi-line long label',
|
||||||
args => [label => 'VERY LONG LABEL:', "foo\nbar"],
|
args => [label => 'VERY LONG LABEL', "foo\nbar"],
|
||||||
want => "VERY LONG LABEL: > foo\nVERY LONG LABEL: bar\n",
|
want => "VERY LONG LABEL: > foo\nVERY LONG LABEL: bar\n",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -87,14 +87,14 @@ my @test_cases = (
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc => 'single line, label, file, and line number',
|
desc => 'single line, label, file, and line number',
|
||||||
args => [label => 'LBL:', 'foo'],
|
args => [label => 'LBL', 'foo'],
|
||||||
file => 'name',
|
file => 'name',
|
||||||
lineno => 42,
|
lineno => 42,
|
||||||
want => "LBL: file name, line 42: > foo\n",
|
want => "LBL: file name, line 42: > foo\n",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc => 'multiple lines, label, file, and line number',
|
desc => 'multiple lines, label, file, and line number',
|
||||||
args => [label => 'LBL:', "foo\nbar"],
|
args => [label => 'LBL', "foo\nbar"],
|
||||||
file => 'name',
|
file => 'name',
|
||||||
lineno => 42,
|
lineno => 42,
|
||||||
want => "LBL: file name, line 42: > foo\nLBL: file name, line 42: bar\n",
|
want => "LBL: file name, line 42: > foo\nLBL: file name, line 42: bar\n",
|
||||||
|
|
Loading…
Reference in a new issue