File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525from typing import Optional
2626
2727import click
28+ from click .core import ParameterSource
2829from fastapi import FastAPI
2930import uvicorn
3031
@@ -615,6 +616,14 @@ def decorator(func):
615616 help = "Optional. Any additional origins to allow for CORS." ,
616617 multiple = True ,
617618 )
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+ )
618627 @click .option (
619628 "--log_level" ,
620629 type = LOG_LEVELS ,
@@ -651,7 +660,16 @@ def decorator(func):
651660 help = "Optional. Whether to enable live reload for agents changes." ,
652661 )
653662 @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+
655673 return func (* args , ** kwargs )
656674
657675 return wrapper
You can’t perform that action at this time.
0 commit comments