Skip to content

Commit

Permalink
Consolidate logging.getLogger() calls
Browse files Browse the repository at this point in the history
Move the self.logger = logging.getLogger() calls to the
base class
  • Loading branch information
mbaldessari authored and hgn committed Nov 16, 2013
1 parent 12019e1 commit c18793c
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions captcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ def __init__(self):
self.captcp = None
self.cc = ConnectionContainer()
self.capture_level = CaptureLevel.NETWORK_LAYER
self.logger = logging.getLogger()

def internal_pre_process_packet(self, ts, packet):
""" this is a hidden preprocessing function, called for every packet"""
Expand Down Expand Up @@ -864,10 +865,8 @@ def set_opts_logevel(self):
class Geoip(Mod):

def initialize(self):
self.logger = logging.getLogger()
self.parse_local_options()


def parse_local_options(self):
parser = optparse.OptionParser()
parser.usage = "geoip"
Expand Down Expand Up @@ -903,7 +902,6 @@ class PayloadTimePortMod(Mod):
DEFAULT_VAL = 0.0

def initialize(self):
self.logger = logging.getLogger()
self.parse_local_options()

self.data = dict()
Expand Down Expand Up @@ -1013,7 +1011,6 @@ class TemplateContainer: pass


def __init__(self):
self.logger = logging.getLogger()
self.init_db()


Expand Down Expand Up @@ -1136,9 +1133,6 @@ class StackTraceMod(Mod):
DEFAULT_FILTER = '*.*.*.*:*-*.*.*.*:5001'

def initialize(self):

self.logger = logging.getLogger()

self.parse_local_options()

sys.stderr.write("# 1. Make sure you have a working systemtap environment\n")
Expand Down Expand Up @@ -1287,7 +1281,6 @@ def initialize(self):
self.v_end = None
self.highest_seq = -1
self.wscale_receiver = 1
self.logger = logging.getLogger()
self.parse_local_options()
self.logger.warning("ADVICE: capture the data at sender side!")

Expand Down Expand Up @@ -1751,7 +1744,6 @@ def initialize(self):
if cairo == None:
raise ImportError("Python Cairo module not available, exiting")

self.logger = logging.getLogger()
self.parse_local_options()
self.setup_cairo()

Expand Down Expand Up @@ -2590,7 +2582,6 @@ def update(self, ts, packet):
class ConnectionAnalyzeMod(Mod):

def initialize(self):
self.logger = logging.getLogger()
parser = optparse.OptionParser()
parser.usage = "captcp connection"
parser.add_option( "-v", "--loglevel", dest="loglevel", default=None,
Expand Down Expand Up @@ -2698,7 +2689,6 @@ def close_data_files(self):


def initialize(self):
self.logger = logging.getLogger()
self.parse_local_options()
self.end_time = self.start_time = False
self.total_data_len = 0
Expand Down Expand Up @@ -2855,7 +2845,6 @@ def process_final(self):
class InFlightMod(Mod):

def initialize(self):
self.logger = logging.getLogger()
self.parse_local_options()
self.packet_sequence = list()
self.packet_prev = False
Expand Down Expand Up @@ -3011,8 +3000,6 @@ def process_final(self):
class SpacingMod(Mod):

def initialize(self):
self.logger = logging.getLogger()

self.parse_local_options()

self.packet_sequence = list()
Expand Down Expand Up @@ -3220,8 +3207,6 @@ class ShowMod(Mod):


def initialize(self):

self.logger = logging.getLogger()
self.parse_local_options()
self.color_iter = self.color.__iter__()
self.packet_no = 0
Expand Down Expand Up @@ -3461,7 +3446,6 @@ def close(self):


def initialize(self):
self.logger = logging.getLogger()
self.parse_local_options()
self.capture_time_start = None
self.last_packet_plus_transmission = None
Expand Down Expand Up @@ -3713,7 +3697,6 @@ class StatisticMod(Mod):

def initialize(self):
self.color = RainbowColor(mode=RainbowColor.ANSI)
self.logger = logging.getLogger()
self.parse_local_options()
self.capture_level = CaptureLevel.NETWORK_LAYER

Expand Down Expand Up @@ -4208,7 +4191,6 @@ class ConnectionAnimationMod(Mod):
REMOTE = 2

def initialize(self):
self.logger = logging.getLogger()
self.parse_local_options()
self.write_js_header()

Expand Down Expand Up @@ -4930,7 +4912,6 @@ def initialize(self):
self.timeframe_start = None
self.timeframe_end = None

self.logger = logging.getLogger()
self.parse_local_options()
self.db = dict()
self.sleep_time = 1.0 / self.opts.sampling_rate
Expand Down

0 comments on commit c18793c

Please sign in to comment.