Another update for an Issue #287

This commit is contained in:
Miroslav Stampar 2012-12-12 14:22:24 +01:00
parent c3f20a136f
commit 921000bd87
2 changed files with 8 additions and 14 deletions

View File

@ -12,6 +12,7 @@ import StringIO
import sys
import time
import traceback
import types
import warnings
warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning)
@ -34,7 +35,7 @@ from lib.core.exception import exceptionsTuple
from lib.core.exception import SqlmapSilentQuitException
from lib.core.exception import SqlmapUserQuitException
from lib.core.log import FORMATTER
from lib.core.log import setLoggerHandler
from lib.core.log import LOGGER_HANDLER
from lib.core.option import init
from lib.core.profiling import profile
from lib.core.settings import LEGAL_DISCLAIMER
@ -54,16 +55,12 @@ def modulePath():
def xmlRpcServe():
logger.setLevel(logging.INFO)
cmdLineOptions.disableColoring = True
server = XMLRPCServer(cmdLineOptions.xmlRpcPort or XMLRPC_SERVER_PORT)
class _(logging.Handler):
def emit(self, record):
message = stdoutencode(self.format(record))
message = stdoutencode(FORMATTER.format(record))
sys.stdout.write("%s\n" % message)
handler = _()
handler.is_tty = False
handler.disableColoring = True
handler.setFormatter(FORMATTER)
setLoggerHandler(handler)
LOGGER_HANDLER.emit = types.MethodType(emit, LOGGER_HANDLER, type(LOGGER_HANDLER))
sys.stdout = StringIO.StringIO()
sys.stderr = StringIO.StringIO()
server.serve()

View File

@ -17,6 +17,7 @@ logging.addLevelName(CUSTOM_LOGGING.TRAFFIC_IN, "TRAFFIC IN")
LOGGER = logging.getLogger("sqlmapLog")
LOGGER_HANDLER = None
try:
import ctypes
LOGGER_HANDLER = ColorizingStreamHandler(sys.stdout)
@ -31,7 +32,3 @@ FORMATTER = logging.Formatter("\r[%(asctime)s] [%(levelname)s] %(message)s", "%H
LOGGER_HANDLER.setFormatter(FORMATTER)
LOGGER.addHandler(LOGGER_HANDLER)
LOGGER.setLevel(logging.WARN)
def setLoggerHandler(handler):
LOGGER.handlers = []
LOGGER.addHandler(handler)