Richard W.M. Jones
2023-Jun-12 18:27 UTC
[Libguestfs] [PATCH libnbd 2/2] generator: state machine: Be less verbose in debug messages
Logging state transitions in debug mode produces huge amounts of output which is not especially helpful. This change removes this debugging output. This reduces the debug output by approximately two thirds. --- generator/state_machine_generator.ml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/generator/state_machine_generator.ml b/generator/state_machine_generator.ml index 274e290952..52c497646d 100644 --- a/generator/state_machine_generator.ml +++ b/generator/state_machine_generator.ml @@ -380,9 +380,6 @@ let pr " h, &next, blocked\n"; pr " );\n"; pr " if (get_next_state (h) != next) {\n"; - pr " debug (h, \"transition: %%s -> %%s\",\n"; - pr " \"%s\",\n" display_name; - pr " nbd_internal_state_short_string (next));\n"; pr " set_next_state (h, next);\n"; pr " }\n"; pr " return r;\n"; @@ -423,15 +420,6 @@ let pr " case %s:\n" (c_string_of_external_event e); if state != next_state then ( pr " set_next_state (h, %s);\n" next_state.parsed.state_enum; - pr " debug ("; - let print_debug_args () - pr "h, \"event %%s: %%s -> %%s\", "; - pr "\"%s\", \"%s\", \"%s\");" - (string_of_external_event e) - display_name next_state.parsed.display_name; - in - pr_wrap ',' print_debug_args; - pr "\n" ); pr " goto ok;\n"; ) events; -- 2.40.1
Eric Blake
2023-Jun-12 19:38 UTC
[Libguestfs] [PATCH libnbd 2/2] generator: state machine: Be less verbose in debug messages
On Mon, Jun 12, 2023 at 07:27:53PM +0100, Richard W.M. Jones wrote:> Logging state transitions in debug mode produces huge amounts of > output which is not especially helpful. This change removes this > debugging output. This reduces the debug output by approximately two > thirds. > --- > generator/state_machine_generator.ml | 12 ------------ > 1 file changed, 12 deletions(-) > > diff --git a/generator/state_machine_generator.ml b/generator/state_machine_generator.ml > index 274e290952..52c497646d 100644 > --- a/generator/state_machine_generator.ml > +++ b/generator/state_machine_generator.ml > @@ -380,9 +380,6 @@ let > pr " h, &next, blocked\n"; > pr " );\n"; > pr " if (get_next_state (h) != next) {\n"; > - pr " debug (h, \"transition: %%s -> %%s\",\n"; > - pr " \"%s\",\n" display_name; > - pr " nbd_internal_state_short_string (next));\n"; > pr " set_next_state (h, next);\n"; > pr " }\n"; > pr " return r;\n"; > @@ -423,15 +420,6 @@ let > pr " case %s:\n" (c_string_of_external_event e); > if state != next_state then ( > pr " set_next_state (h, %s);\n" next_state.parsed.state_enum; > - pr " debug ("; > - let print_debug_args () > - pr "h, \"event %%s: %%s -> %%s\", "; > - pr "\"%s\", \"%s\", \"%s\");" > - (string_of_external_event e) > - display_name next_state.parsed.display_name; > - in > - pr_wrap ',' print_debug_args; > - pr "\n"All that work Laszlo did to nicely wrap these lines. If we decide to go with a multi-level debug (DEBUG=1 being the default for 'make check', DEBUG=2 for extra-verbose debugging), we'd probably implement that by either adding an argument to the existing debug() macro, or adding yet another macro that takes an explicit level (and the existing debug() macro forwards to the other macro with a level of 1), so it's not too hard to choose which lines are super-verbose-only. But I'm fine with this patch as-is, if we don't have a strong reason to keep the state transitions in the debug logs. Reviewed-by: Eric Blake <eblake at redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Reasonably Related Threads
- [PATCH libnbd 0/2] Two simple patches
- [PATCH libnbd 0/4] lib: Atomically update h->state.
- [PATCH libnbd v3] lib: Atomically update h->state when leaving the locked region.
- [PATCH libnbd 4/4] lib: Atomically update h->state when leaving the locked region.
- [PATCH libnbd 3/4] lib: Add set_state / get_state macros.