def __init__(self, cfg): """host, port: statsD server """ Logger.__init__(self, cfg) try: host, port = cfg.statsd_host self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.connect((host, int(port))) except Exception: self.sock = None
def __init__(self, cfg): """host, port: statsD server """ Logger.__init__(self, cfg) self.prefix = sub(r"^(.+[^.]+)\.*$", "\\g<1>.", cfg.statsd_prefix) try: host, port = cfg.statsd_host self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.connect((host, int(port))) except Exception: self.sock = None
def __init__(self, cfg): Logger.__init__(self, cfg) self.is_statsd = False statsd_server = os.environ.get("statsd") if statsd_server: try: host, port = statsd_server.split(":") self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.connect((host, int(port))) except Exception: self.sock = None else: self.is_statsd = True
def __init__(self, cfg): """host, port: statsD server """ Logger.__init__(self, cfg) self.prefix = sub(r"^(.+[^.]+)\.*$", "\\g<1>.", cfg.statsd_prefix) if cfg.statsd_socket: address_family = socket.AF_UNIX address = cfg.statsd_socket elif cfg.statsd_host: address_family = socket.AF_INET host, port = cfg.statsd_host address = (host, int(port)) try: self.sock = socket.socket(address_family, socket.SOCK_DGRAM) self.sock.connect(address) except Exception: self.sock = None self.dogstatsd_tags = cfg.dogstatsd_tags
def __init__(self, cfg): Logger.__init__(self, cfg)