MCPcopy
hub / github.com/jipegit/OSXAuditor / SyslogSetup

Function SyslogSetup

osxauditor.py:204–218  ·  view source on GitHub ↗

Set the Syslog handler up

(SyslogServer)

Source from the content-addressed store, hash-verified

202 HTML_LOG_CONTENT += u"<i class='icon-wrench'></i> " + LogStr + u"<br>"
203
204def SyslogSetup(SyslogServer):
205 ''' Set the Syslog handler up'''
206
207 global SYSLOG_SERVER
208
209 try:
210 Logger = logging.getLogger()
211 Syslog = logging.handlers.SysLogHandler(address=(SyslogServer, SYSLOG_PORT))
212 Formatter = logging.Formatter('OS X Auditor: ' + HOSTNAME + ' %(levelname)s: %(message)s')
213 Syslog.setFormatter(Formatter)
214 Logger.addHandler(Syslog)
215 SYSLOG_SERVER = True
216 except:
217 PrintAndLog(u'Syslog setup failed, Syslog is disabled', 'ERROR')
218 SYSLOG_SERVER = False
219
220def PrintAndLog(LogStr, TYPE):
221 ''' Write a string of log depending of its type and call the function to generate the HTML log or the Syslog if needed '''

Callers 1

MainFunction · 0.85

Calls 1

PrintAndLogFunction · 0.85

Tested by

no test coverage detected