diff --git a/bw2calc/__init__.py b/bw2calc/__init__.py index 9371b7e..73077fc 100644 --- a/bw2calc/__init__.py +++ b/bw2calc/__init__.py @@ -10,10 +10,11 @@ __version__ = "2.0.DEV16" -import json_logging import platform import warnings +import json_logging + json_logging.init_non_web(enable_json=True) ARM = {"arm", "arm64", "aarch64_be", "aarch64", "armv8b", "armv8l"} diff --git a/bw2calc/log_utils.py b/bw2calc/log_utils.py index b73a78f..db98bf2 100644 --- a/bw2calc/log_utils.py +++ b/bw2calc/log_utils.py @@ -82,7 +82,7 @@ def json_record(self, message, extra, record): else: # Also support logger.info({'foo': 'bar'}) data = eval(message) - data["time"] = utc_now().isoformat() + 'Z' + data["time"] = utc_now().isoformat() + "Z" if record.exc_info: data["exc_info"] = self.formatException(record.exc_info) @@ -92,11 +92,13 @@ def json_record(self, message, extra, record): def create_logger(dirpath=None, name=None, **kwargs): """Create a ``logger`` instance named ``bw2calc`` that can be used to log calculations. - ``dirpath`` is the directory where the log file is saved. If ``dirpath`` is ``None``, no logger is created. + ``dirpath`` is the directory where the log file is saved. If ``dirpath`` is ``None``, no logger + is created. ``name`` is the name of the calculation run, used to construct the log filepath. - You can add other types of loggers, just add another handler to the ``bw2calc`` named logger before starting your calculations. + You can add other types of loggers, just add another handler to the ``bw2calc`` named logger + before starting your calculations. Returns the filepath of the created log file. @@ -108,7 +110,7 @@ def create_logger(dirpath=None, name=None, **kwargs): assert os.path.isdir(dirpath) and os.access(dirpath, os.W_OK) # Use safe_filepath here - filename = "{}.{}.json".format(name or uuid.uuid4().hex, utc_now().isoformat() + 'Z') + filename = "{}.{}.json".format(name or uuid.uuid4().hex, utc_now().isoformat() + "Z") formatter = JSONFormatter() fp = os.path.abspath(os.path.join(dirpath, filename)) diff --git a/bw2calc/single_value_diagonal_matrix.py b/bw2calc/single_value_diagonal_matrix.py index 3db2b29..7953051 100644 --- a/bw2calc/single_value_diagonal_matrix.py +++ b/bw2calc/single_value_diagonal_matrix.py @@ -51,7 +51,7 @@ def __init__( seed_override: Union[int, None] = None, indexer_override: Any = None, custom_filter: Union[Callable, None] = None, - **kwargs + **kwargs, ): self.dimension = dimension