forked from goodboy/tractor
1
0
Fork 0

Make `log.devx()` level below `.pdb()`

Kinda like a "runtime"-y level for `.pdb()` (which is more or less like
an `.info()` for our debugger subsys) which can be used to report
internals info for those hacking on `.devx` tools.

Also, inject only the *last* 6 digits of the `id(Task)` in
`pformat_task_uid()` output by default.
runtime_to_msgspec
Tyler Goodlet 2024-05-20 16:13:57 -04:00
parent 13bc3c308d
commit e78fdf2f69
1 changed files with 14 additions and 4 deletions

View File

@ -57,8 +57,8 @@ LEVELS: dict[str, int] = {
'TRANSPORT': 5, 'TRANSPORT': 5,
'RUNTIME': 15, 'RUNTIME': 15,
'CANCEL': 16, 'CANCEL': 16,
'DEVX': 400,
'PDB': 500, 'PDB': 500,
'DEVX': 600,
} }
# _custom_levels: set[str] = { # _custom_levels: set[str] = {
# lvlname.lower for lvlname in LEVELS.keys() # lvlname.lower for lvlname in LEVELS.keys()
@ -137,7 +137,7 @@ class StackLevelAdapter(LoggerAdapter):
"Developer experience" sub-sys statuses. "Developer experience" sub-sys statuses.
''' '''
return self.log(600, msg) return self.log(400, msg)
def log( def log(
self, self,
@ -202,7 +202,12 @@ class StackLevelAdapter(LoggerAdapter):
) )
def pformat_task_uid(): # TODO IDEA:
# -[ ] do per task-name and actor-name color coding
# -[ ] unique color per task-id and actor-uuid
def pformat_task_uid(
id_part: str = 'tail'
):
''' '''
Return `str`-ified unique for a `trio.Task` via a combo of its Return `str`-ified unique for a `trio.Task` via a combo of its
`.name: str` and `id()` truncated output. `.name: str` and `id()` truncated output.
@ -210,7 +215,12 @@ def pformat_task_uid():
''' '''
task: trio.Task = trio.lowlevel.current_task() task: trio.Task = trio.lowlevel.current_task()
tid: str = str(id(task)) tid: str = str(id(task))
return f'{task.name}[{tid[:6]}]' if id_part == 'tail':
tid_part: str = tid[-6:]
else:
tid_part: str = tid[:6]
return f'{task.name}[{tid_part}]'
_conc_name_getters = { _conc_name_getters = {