board_inspector: adjust logging levels

The warning, info and debug logging levels are intended to be used in the
following way.

  * Warnings are used when users are expected to be aware of a certain
    failure.
  * Info messages are used to track parsing process and major internal
    errors for development.
  * Debug messages are used to collect verbose debug logs.

To align the current usage of logs to the above guidelines, this patch
adjusts the logging level of the following messages:

  * DSDT/SSDT interpretation failures are now warnings, not information
  * Failures of parsing deferred AML blocks are now information, not debug
    messages

The default log level when running `cli.py` is adjusted to WARNING as well,
as INFO is primarily used for development. A new command line option
`loglevel` is added to adjust the log level per user needs.

v2 -> v3:
  * Make address collisions in ACPI namespace as an info rather than a
    warning.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao 2021-07-04 15:51:28 +08:00 committed by wenlingz
parent 523ce8ad31
commit 774b60ac2d
3 changed files with 11 additions and 5 deletions

View File

@ -431,7 +431,7 @@ class DeferredExpansion(Transformer):
tree.factory = None tree.factory = None
tree.complete_parsing() tree.complete_parsing()
except (DecodeError, DeferLater, ScopeMismatch, UndefinedSymbol) as e: except (DecodeError, DeferLater, ScopeMismatch, UndefinedSymbol) as e:
logging.debug(f"expansion of {tree.label} at {hex(tree.deferred_range[0])} failed due to: " + str(e)) logging.info(f"expansion of {tree.label} at {hex(tree.deferred_range[0])} failed due to: " + str(e))
self.context.pop_scope() self.context.pop_scope()

View File

@ -66,12 +66,18 @@ def main(board_name, board_xml, args):
sys.exit(1) sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("board_name", help="the name of the board that runs the ACRN hypervisor") parser.add_argument("board_name", help="the name of the board that runs the ACRN hypervisor")
parser.add_argument("--out", help="the name of board info file") parser.add_argument("--out", help="the name of board info file")
parser.add_argument("--advanced", action="store_true", default=False, help="extract advanced information such as ACPI namespace") parser.add_argument("--advanced", action="store_true", default=False, help="extract advanced information such as ACPI namespace")
parser.add_argument("--loglevel", default="warning", help="choose log level, e.g. info, warning or error")
args = parser.parse_args() args = parser.parse_args()
try:
logging.basicConfig(level=args.loglevel.upper())
except ValueError:
print(f"{args.loglevel} is not a valid log level")
print(f"Valid log levels (non case-sensitive): critical, error, warning, info, debug")
sys.exit(1)
board_xml = args.out if args.out else f"{args.board_name}.xml" board_xml = args.out if args.out else f"{args.board_name}.xml"
main(args.board_name, board_xml, args) main(args.board_name, board_xml, args)

View File

@ -151,7 +151,7 @@ def fetch_device_info(devices_node, interpreter, namepath):
if isinstance(adr, int): if isinstance(adr, int):
adr = hex(adr) adr = hex(adr)
if len(element.xpath(f"../*[@address='{adr}']")) > 0: if len(element.xpath(f"../*[@address='{adr}']")) > 0:
logging.warning(f"{namepath} has siblings with duplicated address {adr}.") logging.info(f"{namepath} has siblings with duplicated address {adr}.")
else: else:
element.set("address", hex(adr) if isinstance(adr, int) else adr) element.set("address", hex(adr) if isinstance(adr, int) else adr)
@ -188,8 +188,8 @@ def extract(board_etree):
try: try:
namespace = parse_dsdt() namespace = parse_dsdt()
except Exception as e: except Exception as e:
logging.info(f"Parse ACPI DSDT/SSDT failed: {str(e)}") logging.warning(f"Parse ACPI DSDT/SSDT failed: {str(e)}")
logging.info(f"Will not extract information from ACPI DSDT/SSDT") logging.warning(f"Will not extract information from ACPI DSDT/SSDT")
return return
interpreter = ConcreteInterpreter(namespace) interpreter = ConcreteInterpreter(namespace)