Skip to content

Commit e2f139f

Browse files
committed
[#1945] address review
- add DBGLVL_TRACE_MAX - generate debug-messages.rst automatically on make -C doc/sphinx
1 parent 317af48 commit e2f139f

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

doc/sphinx/Makefile.am

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ api_files =
6161
include $(top_srcdir)/src/share/api/api_files.mk
6262

6363
if HAVE_PDFLATEX
64-
all: kea-messages.rst html mans pdf text
64+
all: debug-messages.rst kea-messages.rst html mans pdf text
6565
else
66-
all: kea-messages.rst html mans text
66+
all: debug-messages.rst kea-messages.rst html mans text
6767
endif
6868

6969
# build the list of message files
@@ -73,6 +73,10 @@ mes_files.mk: mes-files.txt
7373
mes-files.txt:
7474
@find ../.. -type f -name '*.mes' | sort -V | sed 's#^../../##g' > $@
7575

76+
# Used in official build process. debug-messages.rst is generated via ./tools/check-messages.py -g.
77+
$(srcdir)/debug-messages.rst: $(srcdir)/../../tools/check-messages.py
78+
$(PYTHON) $< --generate-debug-messages-page
79+
7680
# Used in official build process. kea-messages.rst is generated via mes2doc.py.
7781
$(srcdir)/kea-messages.rst: mes2doc.py
7882
$(PYTHON) $(srcdir)/mes2doc.py -o $@
@@ -222,7 +226,7 @@ update-python-dependencies: ./src/requirements.in
222226
clean-local:
223227
rm -rf $(sphinxbuilddir)
224228
rm -f $(srcdir)/mes-files.txt $(srcdir)/api-files.txt
225-
rm -f $(srcdir)/kea-messages.rst $(srcdir)/api.rst
229+
rm -f $(srcdir)/debug-messages.rst $(srcdir)/kea-messages.rst $(srcdir)/api.rst
226230
rm -f $(srcdir)/arm/platforms.rst
227231

228232
.PHONY: all pdf html mans update-python-dependencies uml uml-to-png uml-to-svg format-svgs uml-to-txt

src/lib/log/log_dbglevels.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern const int DBGLVL_TRACE_DETAIL = 50;
2222
extern const int DBGLVL_TRACE_DETAIL_DATA = 55;
2323
extern const int DBGLVL_TRACE_TECHNICAL = 70;
2424
extern const int DBGLVL_TRACE_TECHNICAL_DATA = 90;
25+
extern const int DBGLVL_TRACE_MAX = 99;
2526

2627
} // namespace log
2728
} // namespace isc

src/lib/log/log_dbglevels.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ extern const int DBGLVL_TRACE_TECHNICAL;
8383
/// @brief Trace data associated with technical operations.
8484
extern const int DBGLVL_TRACE_TECHNICAL_DATA;
8585

86+
/// @brief The highest level of debug logging.
87+
extern const int DBGLVL_TRACE_MAX;
88+
8689
} // log namespace
8790
} // isc namespace
8891

tools/check-messages.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ def check_duplicate_occurences(occurences):
5454

5555

5656
def check_unlogged_messages(messages, autofix):
57-
all_source_files = set(pathlib.Path('.').glob('**/*.cc')) \
58-
- set(pathlib.Path('.').glob('**/*messages.cc')) \
59-
| set(pathlib.Path('.').glob('**/*.h')) \
60-
- set(pathlib.Path('.').glob('**/*messages.h'))
57+
parent_dir = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))
58+
root_dir = f'{parent_dir}/..'
59+
all_source_files = set(pathlib.Path(root_dir).glob('**/*.cc')) \
60+
- set(pathlib.Path(root_dir).glob('**/*messages.cc')) \
61+
| set(pathlib.Path(root_dir).glob('**/*.h')) \
62+
- set(pathlib.Path(root_dir).glob('**/*messages.h'))
6163
all_source_code = ''
6264
for file in all_source_files:
6365
with open(file, 'r', encoding='utf-8') as f:
@@ -216,6 +218,8 @@ def main():
216218
formatter_class=argparse.RawTextHelpFormatter)
217219
parser.add_argument('-a', '--autofix', action='store_true',
218220
help='Autofix unused messages and debug log levels in docs.')
221+
parser.add_argument('-g', '--generate-debug-messages-page', action='store_true',
222+
help='Generate the debug-messages.rst file included in the ARM.')
219223
args = parser.parse_args()
220224

221225
# Initializations
@@ -229,7 +233,9 @@ def main():
229233
log_pattern = re.compile(r'\b(LOG_DEBUG|LOG_ERROR|LOG_FATAL|LOG_INFO|LOG_WARN)\(')
230234

231235
# Process .mes files.
232-
mes_files = sorted(pathlib.Path('.').glob('**/*.mes'))
236+
parent_dir = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))
237+
root_dir = f'{parent_dir}/..'
238+
mes_files = sorted(pathlib.Path(root_dir).glob('**/*.mes'))
233239
for mes_file in mes_files:
234240
with open(mes_file, 'r', encoding='utf-8') as f:
235241
current_message_id = None
@@ -265,8 +271,8 @@ def main():
265271
}
266272

267273
# Process .cc and .h files.
268-
cc_files = sorted(pathlib.Path('.').glob('**/*.cc'))
269-
h_files = sorted(pathlib.Path('.').glob('**/*.h'))
274+
cc_files = sorted(pathlib.Path(root_dir).glob('**/*.cc'))
275+
h_files = sorted(pathlib.Path(root_dir).glob('**/*.h'))
270276
cpp_files = cc_files + h_files
271277
for cpp_file in cpp_files:
272278
# Skip test files.
@@ -327,6 +333,11 @@ def main():
327333
for level in debug_levels:
328334
debug_levels[level] = int(debug_levels[level])
329335

336+
if args.autofix or args.generate_debug_messages_page:
337+
generate_page_with_messages_printed_on_each_debug_level(messages, debug_levels)
338+
if args.generate_debug_messages_page:
339+
return
340+
330341
# Get number of occurences for each message id.
331342
for line in log_lines:
332343
pos = 1
@@ -354,9 +365,6 @@ def main():
354365
# 7. Checks that the placeholder ids are consecutive, starting with 1, and unique in the same message definition.
355366
failure |= check_placeholder_ids(messages)
356367

357-
if args.autofix:
358-
generate_page_with_messages_printed_on_each_debug_level(messages, debug_levels)
359-
360368
if failure:
361369
sys.exit(1)
362370

0 commit comments

Comments
 (0)