'Log a given statistic if metric, value and type are present'

def log(self, lvl, msg, *args, **kwargs):

    try:
        extra = kwargs.get('extra', None)
        if (extra is not None):
            metric = extra.get(METRIC_VAR, None)
            value = extra.get(VALUE_VAR, None)
            typ = extra.get(MTYPE_VAR, None)
            if (metric and value and typ):
                if (typ == GAUGE_TYPE):
                    self.gauge(metric, value)
                elif (typ == COUNTER_TYPE):
                    self.increment(metric, value)
                elif (typ == HISTOGRAM_TYPE):
                    self.histogram(metric, value)
                else:
                    pass
        if msg:
            Logger.log(self, lvl, msg, *args, **kwargs)
    except Exception:
        Logger.warning(self, 'Failed    to    log    to    statsd', exc_info=True)
