eastham / adsb_actions

A package for taking actions based on live or recorded ADS-B data.
BSD 2-Clause "Simplified" License
2 stars 0 forks source link

Add time to syslog entries #13

Closed harpermann closed 4 months ago

harpermann commented 6 months ago
harpermann commented 4 months ago

This seems to do the trick. I like writing to the existing syslog files, syslog and user.log since that's where an admin might look for messages. I'm alerting off user.log but syslog gets the entry as well. Probably need rsyslog install but that's simple enough. They are rotated automatically so they don't fill a disk. We can add logs but if we do, we need to manage disk space with logrotate or some similar scheme. Logrotate isn't too complicated.
Note: %(asctime) is the standard syslog time entry which is nice if we need to parse it.

logger = logging.getLogger(__name__)
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s %(levelname)s adsb_actions %(module)s:%(lineno)d: %(message)s',
    handlers=[
        logging.StreamHandler(),
        logging.handlers.SysLogHandler(),
#        logging.FileHandler("log/op_pusher.log"),
    ]
)