Posted to tcl by Bradipo at Tue Jul 23 17:19:57 GMT 2024view raw

  1. proc fmtdate {s} { clock format $s -format {%Y-%m-%d %T: } }
  2. proc fmtlevel {l} { format "%7s" $l }
  3. proc fmtlog {l} { format ": %s" $l }
  4. set f [frame .f]
  5. set t [text $f.t -setgrid 1 -wrap word -height 24 -width 80]
  6. $t tag configure log -lmargin2 .5i -rmargin .128i -lmargincolor red -rmargincolor green
  7. $t tag configure level -foreground blue
  8. $t tag configure datetime -foreground slategrey
  9. pack $f -expand y
  10. pack $t -expand y
  11. $t insert end [fmtdate [clock seconds]] datetime [fmtlevel "urgent"] level [fmtlog [join [lrepeat 5 {These are some words to try.}] { }]\n] log
  12. $t insert end [fmtdate [clock seconds]] datetime [fmtlevel "urgent"] level [fmtlog [join [lrepeat 5 {And these are some other words to try.}] { }]\n] log