diff --git a/stacktach/dbapi.py b/stacktach/dbapi.py index 7b81430..b613525 100644 --- a/stacktach/dbapi.py +++ b/stacktach/dbapi.py @@ -72,7 +72,11 @@ def _log_api_exception(cls, ex, request): line1 = "Exception: %s - %s - %s" % (cls.__name__, ex.status, ex.message) line2 = "Request: %s - %s" % (request.method, request.path) line3 = "Body: %s" % request.body - stacklog.error("%s/n%s/n%s" % (line1, line2, line3)) + msg = "%s\n%s\n%s" % (line1, line2, line3) + if 400 <= ex.status < 500: + stacklog.warn(msg) + else: + stacklog.error(msg) def api_call(func): diff --git a/stacktach/stacklog.py b/stacktach/stacklog.py index 60e2408..8d645e0 100644 --- a/stacktach/stacklog.py +++ b/stacktach/stacklog.py @@ -73,4 +73,4 @@ def warn(msg, name=None): def error(msg, name=None): if name is None: name = default_logger_name - get_logger(name=name).warn(msg) \ No newline at end of file + get_logger(name=name).error(msg) \ No newline at end of file