22from pathlib import Path
33from typing import List
44
5- from deepsearch import DeepSearchConfig
6- from deepsearch .artifacts .cli .main import app as artifacts_app
7- from deepsearch .core .cli .main import app
8- from deepsearch .core .cli .plugins import get_cli_groups
9- from deepsearch .core .util .config_paths import config_file_path
10- from deepsearch .cps .cli .main import app as cps_app
11- from deepsearch .documents .cli .main import app as documents_app
12- from deepsearch .query .cli .main import app as query_app
13-
14- # TODO review if unwanted information is being logged
5+ from deepsearch .core .client .settings_manager import settings_mgr
156
167
178def setup_logger ():
189 # Setting up root logger
19- config_file = config_file_path ()
20-
21- if not config_file .exists ():
22- raise RuntimeError (
23- f"Config file { config_file } does not exist. Please configure your default authentication with `$ deepsearch login`"
24- )
25- config = DeepSearchConfig .parse_file (config_file )
10+ active_profile_settings = settings_mgr .get_profile_settings (
11+ settings_mgr .get_active_profile ()
12+ )
2613
27- p = Path (config . log_configuration . target_file )
14+ p = Path (active_profile_settings . log_target_file )
2815 if not p .parent .is_dir ():
2916 p .parent .mkdir (parents = True )
3017
18+ p = p .joinpath ("deepsearch.log" )
19+
3120 handlers : List [logging .Handler ] = [
3221 logging .FileHandler (p ),
3322 ]
34- if config . log_configuration . write_to_console :
23+ if active_profile_settings . log_to_console :
3524 handlers .append (logging .StreamHandler ())
3625 formatter = logging .Formatter (
3726 "%(asctime)s %(name)s — %(levelname)s — %(module)s:%(funcName)s:%(lineno)d — %(message)s"
@@ -46,18 +35,21 @@ def setup_logger():
4635
4736logger = setup_logger ()
4837
38+ from deepsearch .artifacts .cli .main import app as artifacts_app
39+ from deepsearch .core .cli .main import app
40+ from deepsearch .core .cli .plugins import get_cli_groups
41+ from deepsearch .cps .cli .main import app as cps_app
42+ from deepsearch .documents .cli .main import app as documents_app
43+ from deepsearch .query .cli .main import app as query_app
44+
4945app .add_typer (cps_app , name = "cps" , help = "Interact with DeepSearch CPS component" )
50- logger .info ("Cps module initialized" )
5146app .add_typer (query_app , name = "query" , help = "Interact with DeepSearch Query component" )
52- logger .info ("Query module initialized" )
5347app .add_typer (
5448 documents_app ,
5549 name = "documents" ,
5650 help = "Interact with DeepSearch Document Conversion component" ,
5751)
58- logger .info ("Documents module initialized" )
5952app .add_typer (artifacts_app , name = "artifacts" , help = "Manage artifacts" )
60- logger .info ("Artifacts module initialized" )
6153
6254for group in get_cli_groups ():
6355 app .add_typer (group )
0 commit comments