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
@@ -557,6 +558,14 @@ def decorator(func):
557
558
help = "Optional. Any additional origins to allow for CORS." ,
558
559
multiple = True ,
559
560
)
561
+ @click .option (
562
+ "-v" ,
563
+ "--verbose" ,
564
+ is_flag = True ,
565
+ show_default = True ,
566
+ default = False ,
567
+ help = "Enable verbose (DEBUG) logging. Shortcut for --log_level DEBUG." ,
568
+ )
560
569
@click .option (
561
570
"--log_level" ,
562
571
type = LOG_LEVELS ,
@@ -593,7 +602,16 @@ def decorator(func):
593
602
help = "Optional. Whether to enable live reload for agents changes." ,
594
603
)
595
604
@functools .wraps (func )
596
- def wrapper (* args , ** kwargs ):
605
+ @click .pass_context
606
+ def wrapper (ctx , * args , ** kwargs ):
607
+ # If verbose flag is set and log level is not set, set log level to DEBUG.
608
+ log_level_source = ctx .get_parameter_source ("log_level" )
609
+ if (
610
+ kwargs .pop ("verbose" , False )
611
+ and log_level_source == ParameterSource .DEFAULT
612
+ ):
613
+ kwargs ["log_level" ] = "DEBUG"
614
+
597
615
return func (* args , ** kwargs )
598
616
599
617
return wrapper
You can’t perform that action at this time.
0 commit comments