mitogen icon indicating copy to clipboard operation
mitogen copied to clipboard

ansible: optimize verbosity logging output

Open steadfasterX opened this issue 3 years ago • 0 comments

This is related to: https://github.com/mitogen-hq/mitogen/issues/172 mitogen version: v0.3.3

Unfortunately using -vvv (aka verbosity=3) in ansible is not as verbose as logging.DEBUG in mitogen. in Ansible's verbosity level 3 you get ofc more output but it is still readable - which is not the case for logging.DEBUG in mitogen (imho).

I currently use this instead of: https://github.com/mitogen-hq/mitogen/blob/v0.3.3/ansible_mitogen/logging.py#L118-L130

    if display.verbosity == 2:
        l_ansible_mitogen.setLevel(logging.DEBUG)
        l_mitogen.setLevel(logging.WARNING)
    elif display.verbosity == 3:
        l_ansible_mitogen.setLevel(logging.DEBUG)
        l_mitogen.setLevel(logging.DEBUG)
    elif display.verbosity >= 4:
        l_mitogen_io.setLevel(logging.DEBUG)
        l_ansible_mitogen.setLevel(logging.DEBUG)
    else:
        # Mitogen copies the active log level into new children, allowing them
        # to filter tiny messages before they hit the network, and therefore
        # before they wake the IO loop. Explicitly setting INFO saves ~4%
        # running against just the local machine.
        l_mitogen.setLevel(logging.ERROR)
        l_ansible_mitogen.setLevel(logging.ERROR)

the above:

  • sets explicit levels on each verbosity level
  • sets the logging level of mitogen to WARNING when -vv is used (instead of DEBUG)

dunno if that fits for others but thats how it works for me.

steadfasterX avatar Sep 09 '22 13:09 steadfasterX