From c7979d010089c4bb05ff9c01bba99cb9c1011681 Mon Sep 17 00:00:00 2001 From: goodboy Date: Fri, 13 Feb 2026 15:55:32 -0500 Subject: [PATCH] Enable console logging in `.accounting` on import Enable `get_console_log()` at `.accounting.__init__` import-time to ensure console output is available whenever the subsystem is used by `.clearing` or other code. Deats, - uncomment and complete `get_console_log()` call in `.accounting.__init__` with default `level='warning'` and `name=__name__`. - update comment explaining rationale: better to enable on import since namely used by `.clearing` subsystem. Also, - change `piker.calc` import to relative `.calc` in `.accounting.__init__`. - drop unused `get_console_log` import from `.accounting._pos`. - add `log = get_logger(name=__name__)` to `.accounting.cli`. - change `get_logger(loglevel)` -> `get_console_log()` in `.accounting.cli.sync()` with proper kwargs. - add `get_console_log` import to `.accounting.cli`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/accounting/__init__.py | 12 ++++++++---- piker/accounting/_pos.py | 1 - piker/accounting/cli.py | 12 +++++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/piker/accounting/__init__.py b/piker/accounting/__init__.py index f95c5b65..7a587261 100644 --- a/piker/accounting/__init__.py +++ b/piker/accounting/__init__.py @@ -23,7 +23,7 @@ from piker.log import ( get_console_log, get_logger, ) -from piker.calc import ( +from .calc import ( iter_by_dt, ) from ._ledger import ( @@ -56,10 +56,14 @@ log = get_logger(__name__) # ?TODO, enable console on import # [ ] necessary? or `open_brokerd_dialog()` doing it is sufficient? # -# get_console_log( -# name=__name__, -# ) +# bc might as well enable whenev imported by +# other sub-sys code (namely `.clearing`). +get_console_log( + level='warning', + name=__name__, +) +# TODO, the `as ` style? __all__ = [ 'Account', 'Allocator', diff --git a/piker/accounting/_pos.py b/piker/accounting/_pos.py index bf26c23b..e4577b47 100644 --- a/piker/accounting/_pos.py +++ b/piker/accounting/_pos.py @@ -61,7 +61,6 @@ from ..clearing._messages import ( ) from piker.types import Struct from piker.log import ( - get_console_log, get_logger, ) diff --git a/piker/accounting/cli.py b/piker/accounting/cli.py index f68cdfca..10306898 100644 --- a/piker/accounting/cli.py +++ b/piker/accounting/cli.py @@ -21,7 +21,6 @@ CLI front end for trades ledger and position tracking management. from __future__ import annotations from pprint import pformat - from rich.console import Console from rich.markdown import Markdown import polars as pl @@ -29,7 +28,10 @@ import tractor import trio import typer -from ..log import get_logger +from piker.log import ( + get_console_log, + get_logger, +) from ..service import ( open_piker_runtime, ) @@ -45,6 +47,7 @@ from .calc import ( open_ledger_dfs, ) +log = get_logger(name=__name__) ledger = typer.Typer() @@ -79,7 +82,10 @@ def sync( "-l", ), ): - log = get_logger(loglevel) + log = get_console_log( + level=loglevel, + name=__name__, + ) console = Console() pair: tuple[str, str]