File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -528,3 +528,34 @@ async def test_constraints_on_parameter_and_num(a, assets):
528
528
)
529
529
],
530
530
)
531
+
532
+
533
+ @pytest .mark .asyncio
534
+ async def test_init_db_logging (tmpdir , caplog ):
535
+ config = {
536
+ "database" : {
537
+ "uri" : "sqlite+aiosqlite://" , # in-memory
538
+ },
539
+ "trees" : [
540
+ {
541
+ "tree" : "catalog" ,
542
+ "path" : "/" ,
543
+ "args" : {
544
+ "uri" : f"sqlite+aiosqlite:///{ tmpdir } /catalog.db" ,
545
+ "writable_storage" : str (tmpdir / "data" ),
546
+ "init_if_not_exists" : True ,
547
+ },
548
+ },
549
+ ],
550
+ }
551
+ # Issue 721 notes that the logging of the subprocess that creates
552
+ # a database logs normal things to error. This test looks at the log
553
+ # and fails if an error log happens. This could catch anything that is
554
+ # an error during the app build.
555
+ import logging
556
+
557
+ with caplog .at_level (logging .INFO ):
558
+ app = build_app_from_config (config )
559
+ for record in caplog .records :
560
+ assert record .levelname != "ERROR" , f"Error found creating app { record .msg } "
561
+ assert app
Original file line number Diff line number Diff line change @@ -1397,8 +1397,8 @@ def from_uri(
1397
1397
# Capture stdout and stderr from the subprocess and write to logging
1398
1398
stdout = process .stdout .decode ()
1399
1399
stderr = process .stderr .decode ()
1400
- logging .info (f"Subprocess stdout: { stdout } " )
1401
- logging . error (f"Subprocess stderr: { stderr } " )
1400
+ logger .info (f"Subprocess stdout: { stdout } " )
1401
+ logger . info (f"Subprocess stderr: { stderr } " )
1402
1402
1403
1403
parsed_url = make_url (uri )
1404
1404
if (parsed_url .get_dialect ().name == "sqlite" ) and (
Original file line number Diff line number Diff line change @@ -178,6 +178,10 @@ def serve_directory(
178
178
adapters_by_mimetype = adapters_by_mimetype ,
179
179
)
180
180
if verbose :
181
+ from tiled .catalog .adapter import logger as catalog_logger
182
+
183
+ catalog_logger .addHandler (StreamHandler ())
184
+ catalog_logger .setLevel ("INFO" )
181
185
register_logger .addHandler (StreamHandler ())
182
186
register_logger .setLevel ("INFO" )
183
187
# Set the API key manually here, rather than letting the server do it,
@@ -345,6 +349,12 @@ def serve_catalog(
345
349
log_timestamps : bool = typer .Option (
346
350
False , help = "Include timestamps in log output."
347
351
),
352
+ verbose : bool = typer .Option (
353
+ False ,
354
+ "--verbose" ,
355
+ "-v" ,
356
+ help = ("Log details of catalog creation." ),
357
+ ),
348
358
):
349
359
"Serve a catalog."
350
360
import urllib .parse
@@ -418,6 +428,13 @@ def serve_catalog(
418
428
err = True ,
419
429
)
420
430
raise typer .Abort ()
431
+ elif verbose :
432
+ from logging import StreamHandler
433
+
434
+ from tiled .catalog .adapter import logger as catalog_logger
435
+
436
+ catalog_logger .addHandler (StreamHandler ())
437
+ catalog_logger .setLevel ("INFO" )
421
438
422
439
if write is None :
423
440
typer .echo (
You can’t perform that action at this time.
0 commit comments