2012-07-10 06:00:21 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
2012-07-12 21:38:03 +04:00
|
|
|
Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/)
|
2012-07-10 06:00:21 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from lib.core.enums import CUSTOM_LOGGING
|
2012-07-14 19:01:04 +04:00
|
|
|
from thirdparty.ansistrm.ansistrm import ColorizingStreamHandler
|
2012-07-10 06:00:21 +04:00
|
|
|
|
|
|
|
logging.addLevelName(CUSTOM_LOGGING.PAYLOAD, "PAYLOAD")
|
|
|
|
logging.addLevelName(CUSTOM_LOGGING.TRAFFIC_OUT, "TRAFFIC OUT")
|
|
|
|
logging.addLevelName(CUSTOM_LOGGING.TRAFFIC_IN, "TRAFFIC IN")
|
|
|
|
|
|
|
|
LOGGER = logging.getLogger("sqlmapLog")
|
2012-07-10 16:08:37 +04:00
|
|
|
|
|
|
|
try:
|
|
|
|
import ctypes
|
|
|
|
LOGGER_HANDLER = ColorizingStreamHandler(sys.stdout)
|
2012-07-12 01:40:52 +04:00
|
|
|
LOGGER_HANDLER.level_map[logging.getLevelName("PAYLOAD")] = (None, "cyan", False)
|
|
|
|
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC OUT")] = (None, "magenta", False)
|
|
|
|
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC IN")] = ("magenta", None, False)
|
2012-07-10 16:08:37 +04:00
|
|
|
except ImportError:
|
|
|
|
LOGGER_HANDLER = logging.StreamHandler(sys.stdout)
|
|
|
|
|
2012-07-10 06:00:21 +04:00
|
|
|
FORMATTER = logging.Formatter("\r[%(asctime)s] [%(levelname)s] %(message)s", "%H:%M:%S")
|
|
|
|
|
|
|
|
LOGGER_HANDLER.setFormatter(FORMATTER)
|
|
|
|
LOGGER.addHandler(LOGGER_HANDLER)
|
|
|
|
LOGGER.setLevel(logging.WARN)
|
2012-12-12 17:03:03 +04:00
|
|
|
|
|
|
|
def setLoggerHandler(handler):
|
|
|
|
LOGGER.handlers = []
|
|
|
|
LOGGER.addHandler(handler)
|