屏蔽goagent/BaseHTTPServer网络日志

最近使用goagent发现其使用BaseHTTPServer来写代理服务器,而出现很多不想要的日志信息。


为了去除这些日志:

1.屏蔽class Logging(type(sys)) 中的

    def log(self, level, fmt, *args, **kwargs):
        #sys.stderr.write('%s - [%s] %s\n' % (level, time.ctime()[4:-5], fmt % args))
        return #no output
屏蔽goagent/BaseHTTPServer网络日志_第1张图片
经过第一步之后,发现仍旧有部分日志打印出来了;

2.屏蔽BaseHTTPServer的日志记录:

C:\Python27\Lib\BaseHTTPServer.py

屏蔽goagent/BaseHTTPServer网络日志_第2张图片

    def log_message(self, format, *args):
        """Log an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client host and current date/time are prefixed to
        every message.

        """
        '''
        sys.stderr.write("%s - - [%s] %s\n" %
                         (self.address_string(),
                          self.log_date_time_string(),
                          format%args))
        '''
        pass


你可能感兴趣的:(屏蔽goagent/BaseHTTPServer网络日志)