def METHOD_NAME(self, level, msg):
    if level >= self._level:
        level = "error"
    else:
        level = "warning"
    if self._context:
        file, line = self._context[-1]
        return "%s: %s:%d: %s" % (level, file, line, msg)
    return "%s: %s" % (level, msg)