MCPcopy
hub / github.com/benoitc/gunicorn / log

Method log

gunicorn/instrument/statsd.py:68–93  ·  view source on GitHub ↗

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

(self, lvl, msg, *args, **kwargs)

Source from the content-addressed store, hash-verified

66 self.log(logging.DEBUG, msg, *args, **kwargs)
67
68 def log(self, lvl, msg, *args, **kwargs):
69 """Log a given statistic if metric, value and type are present
70 """
71 try:
72 extra = kwargs.get("extra", None)
73 if extra is not None:
74 metric = extra.get(METRIC_VAR, None)
75 value = extra.get(VALUE_VAR, None)
76 typ = extra.get(MTYPE_VAR, None)
77 if metric and value and typ:
78 if typ == GAUGE_TYPE:
79 self.gauge(metric, value)
80 elif typ == COUNTER_TYPE:
81 self.increment(metric, value)
82 elif typ == HISTOGRAM_TYPE:
83 self.histogram(metric, value)
84 elif typ == TIMER_TYPE:
85 self.timer(metric, value)
86 else:
87 pass
88
89 # Log to parent logger only if there is something to say
90 if msg:
91 Logger.log(self, lvl, msg, *args, **kwargs)
92 except Exception:
93 Logger.warning(self, "Failed to log to statsd", exc_info=True)
94
95 # access logging
96 def access(self, resp, req, environ, request_time):

Callers 2

infoMethod · 0.95
debugMethod · 0.95

Calls 6

gaugeMethod · 0.95
incrementMethod · 0.95
histogramMethod · 0.95
timerMethod · 0.95
getMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected