Permalink
Browse files

Add examples for LOG_CATEGORY_LEVEL/LOG_CATEGORY_ALIAS, LOG_SHOW_CATE…

…GORY and LOG_SHOW_LOCATION
  • Loading branch information...
1 parent 0adb4d1 commit 251247f28aec5e3d9e884aeb3517003457dd5b3c Steven Haryanto (on PC) committed Feb 28, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 lib/Log/Any/App.pm
View
28 lib/Log/Any/App.pm
@@ -1206,6 +1206,34 @@ screen:
-file => "/var/log/foo", # uses general -category_level
-screen => { category_level => {} }; # overrides general -category_level
+You can also do this from the outside the script using environment variable,
+which is more flexible. Encode data structure using JSON:
+
+ % LOG_SHOW_CATEGORY=1 \
+ LOG_CATEGORY_ALIAS='{"-noisy":["Foo","Bar::Baz","Quz"]}' \
+ LOG_CATEGORY_LEVEL='{"-noisy":"off"}' script.pl ...
+
+=head2 Displaying category name
+
+ % LOG_SHOW_CATEGORY=1 script.pl ...
+
+Now instead of:
+
+ [25] Starting baz ritual ...
+
+now log messages will be prefixed with category:
+
+ [cat Foo.Bar][25] Starting baz ritual ...
+
+=head2 Displaying location name
+
+ % LOG_SHOW_LOCATION=1 script.pl ...
+
+Now log messages will be prefixed with location (function/file/line number)
+information:
+
+ [loc Foo::Bar lib/Foo/Bar.pm (12)][25] Starting baz ritual ...
+
=head2 Preventing logging level to be changed from outside the script
Sometimes, for security/audit reasons, you don't want to allow script caller to

0 comments on commit 251247f

Please sign in to comment.