2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 09:13:08 +00:00

workaround python agent when /dev/log is not available (#5051)

This commit is contained in:
Bin Xu 2018-04-03 18:13:55 +08:00 committed by yangsong
parent eb967a72e6
commit f7867c9e51
2 changed files with 10 additions and 3 deletions

View File

@ -23,7 +23,11 @@ def getxCATLog(name=None):
return xl
def enableSyslog(name='xcat'):
h = SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL4)
try:
h = SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL4)
except:
# this will connect localhost:514
h = SysLogHandler(facility=SysLogHandler.LOG_LOCAL4)
h.setFormatter(logging.Formatter('%s: ' % name + '%(levelname)s %(message)s'))
logging.getLogger('xcatagent').addHandler(h)

View File

@ -33,8 +33,11 @@ from hwctl.eventlog import DefaultEventlogManager
from xcatagent import base
import logging
logger = logging.getLogger('xcatagent')
if not logger.handlers:
utils.enableSyslog('xcat.agent')
try:
if not logger.handlers:
utils.enableSyslog('xcat.agent')
except:
pass
HTTP_PROTOCOL = "https://"
PROJECT_URL = "/xyz/openbmc_project"