Allow specify log level for Error exception
For now, all Error exceptions logged with error level, but some exceptions may be expected as correct flow and they shouldn't be logged as errors. NotFoundInCacheError, for example, is raised when there isn't info in cache about introspected node, this case may be handled by not_found_hook, so this wouldn't be error anymore. Change-Id: Ie537ccaef0035b2ef839c34fad0a5e6c9ba8f064
This commit is contained in:
parent
e8ecb99122
commit
dab42173c0
@ -103,9 +103,9 @@ LOG = getProcessingLogger(__name__)
|
|||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
"""Inspector exception."""
|
"""Inspector exception."""
|
||||||
|
|
||||||
def __init__(self, msg, code=400, **kwargs):
|
def __init__(self, msg, code=400, log_level='error', **kwargs):
|
||||||
super(Error, self).__init__(msg)
|
super(Error, self).__init__(msg)
|
||||||
LOG.error(msg, **kwargs)
|
getattr(LOG, log_level)(msg, **kwargs)
|
||||||
self.http_code = code
|
self.http_code = code
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +113,8 @@ class NotFoundInCacheError(Error):
|
|||||||
"""Exception when node was not found in cache during processing."""
|
"""Exception when node was not found in cache during processing."""
|
||||||
|
|
||||||
def __init__(self, msg, code=404):
|
def __init__(self, msg, code=404):
|
||||||
super(NotFoundInCacheError, self).__init__(msg, code)
|
super(NotFoundInCacheError, self).__init__(msg, code,
|
||||||
|
log_level='info')
|
||||||
|
|
||||||
|
|
||||||
def spawn_n(*args, **kwargs):
|
def spawn_n(*args, **kwargs):
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
other:
|
||||||
|
- Log level for error when node was not found in Inspector cache was
|
||||||
|
changed from error to info level. It was done because not_found_hook
|
||||||
|
may handle this case, so this wouldn't be error anymore.
|
Loading…
Reference in New Issue
Block a user