#
# fhem.pl configfile
# Logging FS20/KS300 data into files. For database logging see the
# contrib/91_DbLog.pm
#

attr global logfile /daten/src/git/fhem/debian/fhem/var/log/fhem/fhem-%Y-%m.log
attr global statefile /daten/src/git/fhem/debian/fhem/var/lib/fhem/fhem.save    # where to save the state of the devices
attr global verbose 3                   # "normal" verbosity
attr global port 7072                   # our TCP/IP port (localhost only)
attr global modpath /daten/src/git/fhem/debian/fhem/usr/share/fhem                   # where our FHEM directory is

define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC

define wz FHT 3232          # type FHT, transmitter code 3232 (default value)
define ks1 KS300 1234 250   # type KS300, with 250ml rain / counter


#########################
# Log temperature and actuator changes into a file, its name changes weekly
define wzlog FileLog /var/log/fhem/wz-%Y-%U.log wz:.*(temp|actuator).*

# Make it accessible from 01_FHEMWEB.pm (webpgm2)
# Note: for FHEMWEB large logfiles (one per year) are recommended to be able to
# navigate
attr wzlog logtype fht:Temp

# ks300 log
define kslog  FileLog /var/log/wz-%Y-%U.log ks1:.*H:.*
define avglog FileLog /var/log/avg.log ks1:.*avg.*
attr kslog logtype ks300_1:Temp/Hum,ks300_2:Rain/Wind

##############################
# Alternative log method. It does the same, but it is somewhat slower as it
# starts the shellscript below. Don't forget the "", as some values contain
# paranthesis, and your shell will probably bark.
define tmplog notifyon wz:temp.* "/usr/local/bin/log.sh @ "@ %""

#########################
And here is /usr/local/bin/log.sh, don't forget chmod +x

#!/bin/sh
fname=$1
shift
echo `date +"%Y-%m-%d_%H:%M:%S"` "$*" >> /var/log/$fname.log
