sqlmap/lib/core/log.py

34 lines
1.0 KiB
Python
Raw Normal View History

2012-07-10 06:00:21 +04:00
#!/usr/bin/env python
"""
Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import logging
import sys
from extra.ansistrm.ansistrm import ColorizingStreamHandler
from lib.core.enums import CUSTOM_LOGGING
# sqlmap logger
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")
try:
import ctypes
LOGGER_HANDLER = ColorizingStreamHandler(sys.stdout)
2012-07-11 22:42:18 +04:00
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC OUT")] = (None, "cyan", True)
LOGGER_HANDLER.level_map[logging.getLevelName("TRAFFIC IN")] = (None, "grey", True)
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)