slitaz-base-files rev 162
libtaz.sh: add log function (used in cooer and tazpanel actually and soon by spk)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat May 12 01:53:06 2012 +0200 (2012-05-12) |
parents | 8e29b36366d3 |
children | 1c9fc309b4ad |
files | rootfs/lib/libtaz.sh |
line diff
1.1 --- a/rootfs/lib/libtaz.sh Sat May 12 01:05:16 2012 +0200 1.2 +++ b/rootfs/lib/libtaz.sh Sat May 12 01:53:06 2012 +0200 1.3 @@ -113,6 +113,16 @@ 1.4 [ "$answer" == "$(translate_query y)" ] 1.5 } 1.6 1.7 +# New line for echo -n or gettext. 1.8 newline() { 1.9 echo "" 1.10 } 1.11 + 1.12 +# Log activities, we want first letter capitalized. $logfile should be set 1.13 +# by the script. The log format is suitable for web interfaces like cook. 1.14 +# Usage: echo "Message" | log 1.15 +log() { 1.16 + [ "$logfile" ] || logfile=/var/log/slitaz/libtaz.log 1.17 + grep ^[A-Z] | \ 1.18 + sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $logfile 1.19 +}