File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 25
25
from typing import Optional
26
26
27
27
import click
28
+ from click .core import ParameterSource
28
29
from fastapi import FastAPI
29
30
import uvicorn
30
31
@@ -615,6 +616,14 @@ def decorator(func):
615
616
help = "Optional. Any additional origins to allow for CORS." ,
616
617
multiple = True ,
617
618
)
619
+ @click .option (
620
+ "-v" ,
621
+ "--verbose" ,
622
+ is_flag = True ,
623
+ show_default = True ,
624
+ default = False ,
625
+ help = "Enable verbose (DEBUG) logging. Shortcut for --log_level DEBUG." ,
626
+ )
618
627
@click .option (
619
628
"--log_level" ,
620
629
type = LOG_LEVELS ,
@@ -651,7 +660,16 @@ def decorator(func):
651
660
help = "Optional. Whether to enable live reload for agents changes." ,
652
661
)
653
662
@functools .wraps (func )
654
- def wrapper (* args , ** kwargs ):
663
+ @click .pass_context
664
+ def wrapper (ctx , * args , ** kwargs ):
665
+ # If verbose flag is set and log level is not set, set log level to DEBUG.
666
+ log_level_source = ctx .get_parameter_source ("log_level" )
667
+ if (
668
+ kwargs .pop ("verbose" , False )
669
+ and log_level_source == ParameterSource .DEFAULT
670
+ ):
671
+ kwargs ["log_level" ] = "DEBUG"
672
+
655
673
return func (* args , ** kwargs )
656
674
657
675
return wrapper
You can’t perform that action at this time.
0 commit comments