Skip to content

Commit 9b49c15

Browse files
committed
feat: optional logfire integration
Signed-off-by: Frost Ming <me@frostming.com>
1 parent ba4ba51 commit 9b49c15

3 files changed

Lines changed: 344 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Documentation = "https://bub.build"
4343
[project.scripts]
4444
bub = "bub.__main__:app"
4545

46+
[project.optional-dependencies]
47+
logfire = [
48+
"logfire>=4.31.0",
49+
]
50+
4651
[dependency-groups]
4752
dev = [
4853
"pytest>=7.2.0",

src/bub/__main__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@
77
from bub.framework import BubFramework
88

99

10+
def _instrument_bub() -> None:
11+
try:
12+
import logfire
13+
14+
logfire.configure()
15+
except ImportError:
16+
pass
17+
else:
18+
from loguru import logger
19+
20+
logger.configure(handlers=[logfire.loguru_handler()])
21+
22+
1023
def create_cli_app() -> typer.Typer:
24+
_instrument_bub()
1125
framework = BubFramework()
1226
framework.load_hooks()
1327
app = framework.create_cli_app()

0 commit comments

Comments
 (0)