Write a string of log depending of its type and call the function to generate the HTML log or the Syslog if needed
(LogStr, TYPE)
| 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 ''' |
| 222 | |
| 223 | global HTML_LOG_FILE |
| 224 | global SYSLOG_SERVER |
| 225 | |
| 226 | if TYPE == 'INFO' or 'INFO_RAW': |
| 227 | print(u'[INFO] ' + LogStr) |
| 228 | logging.info(LogStr) |
| 229 | |
| 230 | elif TYPE == 'ERROR': |
| 231 | print(u'[ERROR] ' + LogStr) |
| 232 | logging.error(LogStr) |
| 233 | |
| 234 | elif TYPE == 'WARNING': |
| 235 | print(u'[WARNING] ' + LogStr) |
| 236 | logging.warning(LogStr) |
| 237 | |
| 238 | elif TYPE == 'DEBUG': |
| 239 | print(u'[DEBUG] ' + LogStr) |
| 240 | logging.debug(LogStr) |
| 241 | |
| 242 | elif TYPE == 'SECTION' or TYPE == 'SUBSECTION': |
| 243 | SectionTitle = u'\n#########################################################################################################\n' |
| 244 | SectionTitle += '# #\n' |
| 245 | SectionTitle += '# ' +LogStr+ ' '*(94-len(LogStr)) + '#\n' |
| 246 | SectionTitle += '# #\n' |
| 247 | SectionTitle += '#########################################################################################################\n' |
| 248 | print(SectionTitle) |
| 249 | logging.info(u'\n' + SectionTitle) |
| 250 | |
| 251 | if HTML_LOG_FILE: |
| 252 | HTMLLog(LogStr, TYPE) |
| 253 | |
| 254 | def MHRLookup(): |
| 255 | ''' Perform of lookup in Team Cymru\'s MHR ''' |
no test coverage detected