Set the Syslog handler up
(SyslogServer)
| 202 | HTML_LOG_CONTENT += u"<i class='icon-wrench'></i> " + LogStr + u"<br>" |
| 203 | |
| 204 | def 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 | |
| 220 | def 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 ''' |