Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support LOG_SHOW_LOCATION

  • Loading branch information...
commit 45c41f4d589fcba36123b8eef4631355f3432089 1 parent f40d3c6
Steven Haryanto (on PC) authored
Showing with 18 additions and 4 deletions.
  1. +17 −4 lib/Log/Any/App.pm
  2. +1 −0  t/01-basics.t
21 lib/Log/Any/App.pm
View
@@ -30,6 +30,7 @@ my %PATTERN_STYLES = (
);
for (keys %PATTERN_STYLES) {
$PATTERN_STYLES{"cat_$_"} = "[cat %c]$PATTERN_STYLES{$_}";
+ $PATTERN_STYLES{"loc_$_"} = "[loc %l]$PATTERN_STYLES{$_}";
}
my $init_args;
@@ -485,6 +486,12 @@ sub _parse_opt_OUTPUT {
}
}
+sub _set_pattern_style {
+ my ($x) = @_;
+ ($ENV{LOG_SHOW_LOCATION} ? 'loc_':
+ $ENV{LOG_SHOW_CATEGORY} ? 'cat_':'') . $x;
+}
+
sub _default_file {
my ($spec) = @_;
my $level = _set_level("file", "file", $spec);
@@ -504,7 +511,7 @@ sub _default_file {
date_pattern => undef,
tz => undef,
category => '',
- pattern_style => ($ENV{LOG_SHOW_CATEGORY} ? 'cat_':'') . 'daemon',
+ pattern_style => _set_pattern_style('daemon'),
pattern => undef,
};
}
@@ -552,7 +559,7 @@ sub _default_dir {
max_age => undef,
histories => undef,
category => '',
- pattern_style => ($ENV{LOG_SHOW_CATEGORY} ? 'cat_':'') . 'plain',
+ pattern_style => _set_pattern_style('plain'),
pattern => undef,
filename_pattern => undef,
};
@@ -586,7 +593,7 @@ sub _default_screen {
$ENV{LOG_CATEGORY_LEVEL},
$spec->{category_level}),
category => '',
- pattern_style => ($ENV{LOG_SHOW_CATEGORY} ? 'cat_':'') . 'script_short',
+ pattern_style => _set_pattern_style('script_short'),
pattern => undef,
};
}
@@ -613,7 +620,7 @@ sub _default_syslog {
$spec->{category_level}),
ident => $spec->{name},
facility => 'daemon',
- pattern_style => ($ENV{LOG_SHOW_CATEGORY} ? 'cat_':'') . 'syslog',
+ pattern_style => _set_pattern_style('syslog'),
pattern => undef,
category => '',
};
@@ -1521,6 +1528,12 @@ mainly to show categories and then filter by categories. You can turn picking
default pattern style with category using environment variable
LOG_SHOW_CATEGORY.
+And for each of the above there are also C<loc_XXX> (e.g. C<loc_syslog>) which
+are the same as XXX but with C<[loc %l]> in front of the pattern. It is used to
+show calling location (file, function/method, and line number). You can turn
+picking default pattern style with location prefix using environment variable
+LOG_SHOW_LOCATION.
+
If you have a favorite pattern style, please do share them.
1  t/01-basics.t
View
@@ -231,5 +231,6 @@ test_init(
# XXX test LOG_SHOW_CATEGORY
# XXX test LOG_CATEGORY_ALIAS & LOG_CATEGORY_LEVEL & ${OUT}_LOG_CATEGORY_LEVEL
+# XXX test LOG_SHOW_LOCATION
done_testing();
Please sign in to comment.
Something went wrong with that request. Please try again.