Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 921000b

Browse files
committed
Another update for an Issue #287
1 parent c3f20a1 commit 921000b

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

_sqlmap.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import time
1414
import traceback
15+
import types
1516
import warnings
1617

1718
warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning)
@@ -34,7 +35,7 @@
3435
from lib.core.exception import SqlmapSilentQuitException
3536
from lib.core.exception import SqlmapUserQuitException
3637
from lib.core.log import FORMATTER
37-
from lib.core.log import setLoggerHandler
38+
from lib.core.log import LOGGER_HANDLER
3839
from lib.core.option import init
3940
from lib.core.profiling import profile
4041
from lib.core.settings import LEGAL_DISCLAIMER
@@ -54,16 +55,12 @@ def modulePath():
5455

5556
def xmlRpcServe():
5657
logger.setLevel(logging.INFO)
58+
cmdLineOptions.disableColoring = True
5759
server = XMLRPCServer(cmdLineOptions.xmlRpcPort or XMLRPC_SERVER_PORT)
58-
class _(logging.Handler):
59-
def emit(self, record):
60-
message = stdoutencode(self.format(record))
61-
sys.stdout.write("%s\n" % message)
62-
handler = _()
63-
handler.is_tty = False
64-
handler.disableColoring = True
65-
handler.setFormatter(FORMATTER)
66-
setLoggerHandler(handler)
60+
def emit(self, record):
61+
message = stdoutencode(FORMATTER.format(record))
62+
sys.stdout.write("%s\n" % message)
63+
LOGGER_HANDLER.emit = types.MethodType(emit, LOGGER_HANDLER, type(LOGGER_HANDLER))
6764
sys.stdout = StringIO.StringIO()
6865
sys.stderr = StringIO.StringIO()
6966
server.serve()

lib/core/log.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
LOGGER = logging.getLogger("sqlmapLog")
1919

20+
LOGGER_HANDLER = None
2021
try:
2122
import ctypes
2223
LOGGER_HANDLER = ColorizingStreamHandler(sys.stdout)
@@ -31,7 +32,3 @@
3132
LOGGER_HANDLER.setFormatter(FORMATTER)
3233
LOGGER.addHandler(LOGGER_HANDLER)
3334
LOGGER.setLevel(logging.WARN)
34-
35-
def setLoggerHandler(handler):
36-
LOGGER.handlers = []
37-
LOGGER.addHandler(handler)

0 commit comments

Comments
 (0)