Skip to content

Commit 2d204af

Browse files
committed
Propagate log level to UDF app
1 parent 57e35c9 commit 2d204af

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

singlestoredb/apps/_python_udfs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ async def run_udf_app(
4747
udf_suffix = ''
4848
if app_config.running_interactively:
4949
udf_suffix = '_test'
50-
app = Application(url=base_url, app_mode='managed', name_suffix=udf_suffix)
50+
app = Application(
51+
url=base_url,
52+
app_mode='managed',
53+
name_suffix=udf_suffix,
54+
log_level=log_level,
55+
)
5156

5257
if not app.endpoints:
5358
raise ValueError('You must define at least one function.')

singlestoredb/functions/ext/asgi.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,6 @@ def __init__(
862862
name_suffix: str = get_option('external_function.name_suffix'),
863863
function_database: Optional[str] = None,
864864
log_file: Optional[str] = get_option('external_function.log_file'),
865-
866865
log_level: str = get_option('external_function.log_level'),
867866
disable_metrics: bool = get_option('external_function.disable_metrics'),
868867
app_name: Optional[str] = get_option('external_function.app_name'),
@@ -1326,9 +1325,11 @@ def get_function_info(
13261325
) -> Dict[str, Any]:
13271326
"""
13281327
Return the functions and function signature information.
1328+
13291329
Returns
13301330
-------
13311331
Dict[str, Any]
1332+
13321333
"""
13331334
functions = {}
13341335
no_default = object()
@@ -1849,7 +1850,6 @@ def main(argv: Optional[List[str]] = None) -> None:
18491850
),
18501851
help='File path to write logs to instead of console',
18511852
)
1852-
18531853
parser.add_argument(
18541854
'--disable-metrics', action='store_true',
18551855
default=defaults.get(
@@ -1999,11 +1999,11 @@ def main(argv: Optional[List[str]] = None) -> None:
19991999
raise RuntimeError('no functions specified')
20002000

20012001
for f in funcs:
2002-
logger.info(f)
2002+
app.logger.info(f)
20032003

20042004
try:
20052005
if args.db:
2006-
logger.info('Registering functions with database')
2006+
app.logger.info('Registering functions with database')
20072007
app.register_functions(
20082008
args.db,
20092009
replace=args.replace_existing,
@@ -2068,7 +2068,7 @@ def main(argv: Optional[List[str]] = None) -> None:
20682068

20692069
finally:
20702070
if not use_async and args.db:
2071-
logger.info('Dropping functions from database')
2071+
app.logger.info('Dropping functions from database')
20722072
app.drop_functions(args.db)
20732073

20742074

@@ -2081,7 +2081,7 @@ async def _run_uvicorn(
20812081
"""Run uvicorn server and clean up functions after shutdown."""
20822082
await uvicorn.Server(uvicorn.Config(app, **app_args)).serve()
20832083
if db:
2084-
logger.info('Dropping functions from database')
2084+
app.logger.info('Dropping functions from database')
20852085
app.drop_functions(db)
20862086

20872087

0 commit comments

Comments
 (0)