forked from goodboy/tractor
Use `Context` repr APIs for RPC outcome logs
Delegate to the new `.repr_state: str` and adjust log level based on error vs. cancel vs. result.runtime_to_msgspec
parent
4a270f85ca
commit
21f633a900
|
@ -739,37 +739,24 @@ async def _invoke(
|
||||||
cid,
|
cid,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
logmeth: Callable = log.runtime
|
||||||
merr: Exception|None = ctx.maybe_error
|
merr: Exception|None = ctx.maybe_error
|
||||||
(
|
descr_str: str = 'with final result `{repr(ctx.outcome)}`'
|
||||||
res_type_str,
|
|
||||||
res_str,
|
|
||||||
) = (
|
|
||||||
('error', f'{type(merr)}',) if merr
|
|
||||||
else (
|
|
||||||
'result',
|
|
||||||
f'`{repr(ctx.outcome)}`',
|
|
||||||
)
|
|
||||||
)
|
|
||||||
message: str = (
|
message: str = (
|
||||||
f'IPC context terminated with a final {res_type_str}\n\n'
|
f'IPC context terminated {descr_str}\n\n'
|
||||||
f'{ctx}'
|
|
||||||
)
|
)
|
||||||
if merr:
|
if merr:
|
||||||
from tractor import RemoteActorError
|
descr_str: str = (
|
||||||
if not isinstance(merr, RemoteActorError):
|
f'with ctx having {ctx.repr_state!r}\n'
|
||||||
fmt_merr: str = (
|
f'{ctx.repr_outcome()}\n'
|
||||||
f'\n{merr!r}\n'
|
|
||||||
# f'{merr.args[0]!r}\n'
|
|
||||||
)
|
)
|
||||||
|
if isinstance(merr, ContextCancelled):
|
||||||
|
logmeth: Callable = log.runtime
|
||||||
else:
|
else:
|
||||||
fmt_merr = f'\n{merr!r}'
|
logmeth: Callable = log.error
|
||||||
log.error(
|
message += f'\n{merr!r}\n'
|
||||||
message
|
|
||||||
+
|
logmeth(message)
|
||||||
fmt_merr
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
log.runtime(message)
|
|
||||||
|
|
||||||
|
|
||||||
async def try_ship_error_to_remote(
|
async def try_ship_error_to_remote(
|
||||||
|
|
Loading…
Reference in New Issue