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
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