| # Copyright (c) 2022 Nordic Semiconductor ASA |
| # SPDX-License-Identifier: Apache-2.0 |
| Common code used when logging that is needed by multiple modules. |
| _WINDOWS = (platform.system() == 'Windows') |
| def log_command(logger, msg, args): |
| '''Platform-independent helper for logging subprocess invocations. |
| Will log a command string that can be copy/pasted into a POSIX |
| shell on POSIX platforms. This is not available on Windows, so |
| the entire args array is logged instead. |
| :param logger: logging.Logger to use |
| :param msg: message to associate with the command |
| :param args: argument list as passed to subprocess module |
| logger.debug(msg, str(args)) |
| logger.debug(msg, shlex.join(args)) |