Skip to content

Commit 0cd1de3

Browse files
committed
cli: add switch to enable debug for a list of modules
1 parent 5e50358 commit 0cd1de3

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

compdb/cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ def main(argv=None):
237237
dest='help',
238238
action='store_true',
239239
help='show this help message and exit')
240+
group.add_argument(
241+
'--debug',
242+
help="turn on debug logs for the specified modules",
243+
dest="loggers_to_debug",
244+
metavar='MODULE',
245+
action='append',
246+
default=[])
240247
group.add_argument(
241248
'--trace',
242249
dest='loglevel',
@@ -256,6 +263,10 @@ def main(argv=None):
256263

257264
args = parser.parse_args(argv)
258265

266+
logging.basicConfig(level=args.loglevel or logging.WARNING)
267+
for logger_name in args.loggers_to_debug:
268+
logging.getLogger(logger_name).setLevel(logging.DEBUG)
269+
259270
config = Config()
260271
config.build_directory_patterns.extend(args.build_paths)
261272

contrib/zsh/all-helps.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ usage: compdb [general options] command [command options] [command arguments]
33
compdb: the compilation database Swiss army knife
44

55
general options:
6-
-h, --help show this help message and exit
7-
--trace trace execution
8-
-p BUILD_DIR build path(s)
6+
-h, --help show this help message and exit
7+
--debug MODULE turn on debug logs for the specified modules
8+
--trace trace execution
9+
-p BUILD_DIR build path(s)
910

1011
available commands:
1112
help show general or command help

contrib/zsh/check-all-helps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cd $(dirname "${BASH_SOURCE[0]}")
66

77
compdb --help > all-helps.txt.new
88

9-
compdb help | grep "^ [^-]" | while read command descr; do
9+
compdb help | grep "^ [a-z]" | while read command descr; do
1010
echo
1111
echo
1212
echo "# $command"

contrib/zsh/functions/_compdb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ _compdb() {
4040
base_opts=(
4141
'(- :)'{-h,--help}'[show help message and exit]'
4242
'*-p[build path]:build directory:_files -/'
43+
'*--debug[turn on debug logs for the specified modules]:module:'
4344
'--trace[trace execution]'
4445
)
4546

0 commit comments

Comments
 (0)