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-codefix_tractor_logging
parent
9a97c477e2
commit
c7979d0100
|
|
@ -23,7 +23,7 @@ from piker.log import (
|
||||||
get_console_log,
|
get_console_log,
|
||||||
get_logger,
|
get_logger,
|
||||||
)
|
)
|
||||||
from piker.calc import (
|
from .calc import (
|
||||||
iter_by_dt,
|
iter_by_dt,
|
||||||
)
|
)
|
||||||
from ._ledger import (
|
from ._ledger import (
|
||||||
|
|
@ -56,10 +56,14 @@ log = get_logger(__name__)
|
||||||
# ?TODO, enable console on import
|
# ?TODO, enable console on import
|
||||||
# [ ] necessary? or `open_brokerd_dialog()` doing it is sufficient?
|
# [ ] necessary? or `open_brokerd_dialog()` doing it is sufficient?
|
||||||
#
|
#
|
||||||
# get_console_log(
|
# bc might as well enable whenev imported by
|
||||||
# name=__name__,
|
# other sub-sys code (namely `.clearing`).
|
||||||
# )
|
get_console_log(
|
||||||
|
level='warning',
|
||||||
|
name=__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO, the `as <samename>` style?
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'Account',
|
'Account',
|
||||||
'Allocator',
|
'Allocator',
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ from ..clearing._messages import (
|
||||||
)
|
)
|
||||||
from piker.types import Struct
|
from piker.types import Struct
|
||||||
from piker.log import (
|
from piker.log import (
|
||||||
get_console_log,
|
|
||||||
get_logger,
|
get_logger,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ CLI front end for trades ledger and position tracking management.
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
|
||||||
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.markdown import Markdown
|
from rich.markdown import Markdown
|
||||||
import polars as pl
|
import polars as pl
|
||||||
|
|
@ -29,7 +28,10 @@ import tractor
|
||||||
import trio
|
import trio
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
from ..log import get_logger
|
from piker.log import (
|
||||||
|
get_console_log,
|
||||||
|
get_logger,
|
||||||
|
)
|
||||||
from ..service import (
|
from ..service import (
|
||||||
open_piker_runtime,
|
open_piker_runtime,
|
||||||
)
|
)
|
||||||
|
|
@ -45,6 +47,7 @@ from .calc import (
|
||||||
open_ledger_dfs,
|
open_ledger_dfs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
log = get_logger(name=__name__)
|
||||||
|
|
||||||
ledger = typer.Typer()
|
ledger = typer.Typer()
|
||||||
|
|
||||||
|
|
@ -79,7 +82,10 @@ def sync(
|
||||||
"-l",
|
"-l",
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
log = get_logger(loglevel)
|
log = get_console_log(
|
||||||
|
level=loglevel,
|
||||||
|
name=__name__,
|
||||||
|
)
|
||||||
console = Console()
|
console = Console()
|
||||||
|
|
||||||
pair: tuple[str, str]
|
pair: tuple[str, str]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue