Advertisement
urbasus

tagged logging

Aug 24th, 2019
1,213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 0.72 KB | None | 0 0
  1. package provide tlog 1.0.0
  2.  
  3. proc tlog {tags msg} {
  4.     foreach b $tlog::black {
  5.         if {-1!=[lsearch $tlog::match $tags $b]} {
  6.             return; # tag was on black list, don't print
  7.         }
  8.     }
  9.     foreach w $tlog::white {
  10.         if {-1!=[lsearch $tlog::match $tags $w]} {
  11.             tlog::print $tags [uplevel [list subst $msg]]; # tag was on white list, print and return
  12.             return;
  13.         }
  14.     }
  15. }
  16.  
  17. namespace eval tlog {
  18.     proc white args { variable white {*}$args }; variable white *
  19.     proc black args { variable black {*}$args }; variable black {}
  20.     proc match args { variable match {*}$args }; variable match -glob
  21.  
  22.     proc print {tags msg} {
  23.         puts stderr $msg
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement