Skip to content

Commit 614f191

Browse files
committed
refactor: improve error logging with log.exception()
1 parent 9e2b218 commit 614f191

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/gitpod/lib/disposables.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from typing import Any, Callable, List
22
import logging
33

4+
log = logging.getLogger(__name__)
5+
46
class Disposables:
57
"""A utility class to manage cleanup actions (disposables) in a LIFO order.
68
@@ -44,5 +46,5 @@ def cleanup(self) -> None:
4446
for action in reversed(self._actions):
4547
try:
4648
action()
47-
except BaseException as e:
48-
logging.warning(f"Cleanup action failed: {e}")
49+
except BaseException:
50+
log.exception("cleanup action failed")

src/gitpod/lib/environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ async def _update_environment(self):
4343
for listener in list(self._listeners):
4444
try:
4545
listener(env)
46-
except Exception as e:
47-
log.error(f"Error in environment listener: {e}")
48-
except BaseException as e:
49-
log.error(f"Error in environment update: {e}")
46+
except Exception:
47+
log.exception("failed to call listener")
48+
except BaseException:
49+
log.exception("failed to update environment")
5050

5151
async def _start_update_loop(self):
5252
"""Background coroutine that maintains the event stream"""
@@ -86,8 +86,8 @@ async def _start_update_loop(self):
8686
except BaseException as e:
8787
if self._should_stop or isinstance(e, asyncio.CancelledError):
8888
break
89-
90-
log.warning(f"Error in event stream, retrying in {retry_delay}s: {e}")
89+
90+
log.exception("error in event stream, retrying in %s seconds", retry_delay)
9191
await asyncio.sleep(retry_delay)
9292
retry_delay = min(retry_delay * 2, max_delay)
9393

0 commit comments

Comments
 (0)