How to output to syslog before /dev/log exists?

Y

yanegomi

Basically I'm trying to write a snippet of code that outputs to both syslog and the console at boot on a FreeBSD box, and I'm not 100% sure how todirect the SysLogHandler to use the dmesg buffer instead of trying to use either localhost:514 (and failing silently), or use /dev/log (and throwing an Exception at boot). Here's an example of what I was trying to use:

import logging
import logging.handlers

# ...

LOG_FORMAT = '<%(name)s> %(message)s'
logging.basicConfig(format=LOG_FORMAT)
logger = logging.getLogger('root')
slh = logging.handlers.SysLogHandler(address='/dev/log') # XXX: Does not work if /dev/log doesn't exist -- for obvious reasons.
slh.setFormatter(logging.Formatter(fmt=LOG_FORMAT))
logger.addHandler(slh)

Hints within documentation is welcome and appreciated (the terms that needed to be looked for on Google are failing me right now :)..).
Thanks!
-Garrett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top