Skip to content

Commit ea18568

Browse files
committed
turn down log noise. Fix duplicate initialization
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 1aacf2b commit ea18568

7 files changed

Lines changed: 16 additions & 20 deletions

File tree

src/basic_memory/cli/main.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616
sync,
1717
tool,
1818
)
19-
from basic_memory.config import app_config
20-
from basic_memory.services.initialization import ensure_initialization
2119

2220
if __name__ == "__main__": # pragma: no cover
23-
# Run initialization if we are starting as main
24-
# if running via a typer command, initialization is already run in cli/app.py
25-
ensure_initialization(app_config)
26-
2721
# start the app
2822
app()

src/basic_memory/repository/repository.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ async def find_one(self, query: Select[tuple[T]]) -> Optional[T]:
192192
entity = result.scalars().one_or_none()
193193

194194
if entity:
195-
logger.debug(f"Found {self.Model.__name__}: {getattr(entity, 'id', None)}")
195+
logger.trace(f"Found {self.Model.__name__}: {getattr(entity, 'id', None)}")
196196
else:
197-
logger.debug(f"No {self.Model.__name__} found")
197+
logger.trace(f"No {self.Model.__name__} found")
198198
return entity
199199

200200
async def create(self, data: dict) -> T:
@@ -358,12 +358,12 @@ async def execute_query(
358358
"""Execute a query asynchronously."""
359359

360360
query = query.options(*self.get_load_options()) if use_query_options else query
361-
logger.debug(f"Executing query: {query}, params: {params}")
361+
logger.trace(f"Executing query: {query}, params: {params}")
362362
async with db.scoped_session(self.session_maker) as session:
363363
result = await session.execute(query, params)
364364
return result
365365

366366
def get_load_options(self) -> List[LoaderOption]:
367367
"""Get list of loader options for eager loading relationships.
368368
Override in subclasses to specify what to load."""
369-
return []
369+
return []

src/basic_memory/repository/search_repository.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ async def search(
291291
for row in rows
292292
]
293293

294-
logger.debug(f"Found {len(results)} search results")
294+
logger.trace(f"Found {len(results)} search results")
295295
for r in results:
296-
logger.debug(
296+
logger.trace(
297297
f"Search result: project_id: {r.project_id} type:{r.type} title: {r.title} permalink: {r.permalink} score: {r.score}"
298298
)
299299

src/basic_memory/services/initialization.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ async def migrate_legacy_projects(app_config: BasicMemoryConfig):
8686
await migrate_legacy_project_data(project, legacy_dir)
8787
logger.info("Legacy projects successfully migrated")
8888

89+
8990
async def migrate_legacy_project_data(project: Project, legacy_dir: Path) -> bool:
9091
"""Check if project has legacy .basic-memory dir and migrate if needed.
9192
@@ -189,6 +190,7 @@ async def initialize_app(
189190
Args:
190191
app_config: The Basic Memory project configuration
191192
"""
193+
logger.info("Initializing app...")
192194
# Initialize database first
193195
await initialize_database(app_config)
194196

src/basic_memory/services/link_resolver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, entity_repository: EntityRepository, search_service: SearchSe
2828

2929
async def resolve_link(self, link_text: str, use_search: bool = True) -> Optional[Entity]:
3030
"""Resolve a markdown link to a permalink."""
31-
logger.debug(f"Resolving link: {link_text}")
31+
logger.trace(f"Resolving link: {link_text}")
3232

3333
# Clean link text and extract any alias
3434
clean_text, alias = self._normalize_link_text(link_text)
@@ -62,7 +62,7 @@ async def resolve_link(self, link_text: str, use_search: bool = True) -> Optiona
6262
if results:
6363
# Look for best match
6464
best_match = min(results, key=lambda x: x.score) # pyright: ignore
65-
logger.debug(
65+
logger.trace(
6666
f"Selected best match from {len(results)} results: {best_match.permalink}"
6767
)
6868
if best_match.permalink:
@@ -94,4 +94,4 @@ def _normalize_link_text(self, link_text: str) -> Tuple[str, Optional[str]]:
9494
text = text.strip()
9595
alias = alias.strip()
9696

97-
return text, alias
97+
return text, alias

src/basic_memory/services/search_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def search(self, query: SearchQuery, limit=10, offset=0) -> List[SearchInd
6666
logger.debug("no criteria passed to query")
6767
return []
6868

69-
logger.debug(f"Searching with query: {query}")
69+
logger.trace(f"Searching with query: {query}")
7070

7171
after_date = (
7272
(

src/basic_memory/sync/sync_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ async def sync_file(
219219
return entity, checksum
220220

221221
except Exception as e: # pragma: no cover
222-
logger.exception("Failed to sync file", path=path, error=str(e))
222+
logger.error(f"Failed to sync file: path={path}, error={str(e)}")
223223
return None, None
224224

225225
async def sync_markdown_file(self, path: str, new: bool = True) -> Tuple[Optional[Entity], str]:
@@ -427,7 +427,7 @@ async def resolve_relations(self):
427427
logger.info("Resolving forward references", count=len(unresolved_relations))
428428

429429
for relation in unresolved_relations:
430-
logger.debug(
430+
logger.trace(
431431
"Attempting to resolve relation "
432432
f"relation_id={relation.id} "
433433
f"from_id={relation.from_id} "
@@ -495,7 +495,7 @@ async def scan_directory(self, directory: Path) -> ScanResult:
495495
result.files[rel_path] = checksum
496496
result.checksums[checksum] = rel_path
497497

498-
logger.debug(f"Found file, path={rel_path}, checksum={checksum}")
498+
logger.trace(f"Found file, path={rel_path}, checksum={checksum}")
499499

500500
duration_ms = int((time.time() - start_time) * 1000)
501501
logger.debug(
@@ -505,4 +505,4 @@ async def scan_directory(self, directory: Path) -> ScanResult:
505505
f"duration_ms={duration_ms}"
506506
)
507507

508-
return result
508+
return result

0 commit comments

Comments
 (0)