Skip to content

Commit

Permalink
Merge pull request qiskit-community/qiskit-aqua#803 from manoelmarque…
Browse files Browse the repository at this point in the history
…s/provider

Refactor logging methods
  • Loading branch information
manoelmarques authored Jan 31, 2020
2 parents 2064821 + d6e7b27 commit fbb69a9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
8 changes: 7 additions & 1 deletion qiskit/optimization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
# (C) Copyright IBM 2019, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -28,3 +28,9 @@
ising
"""

from ._logging import (get_qiskit_optimization_logging,
set_qiskit_optimization_logging)

__all__ = ['get_qiskit_optimization_logging',
'set_qiskit_optimization_logging']
41 changes: 41 additions & 0 deletions qiskit/optimization/_logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-

# This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Utilities for Optimization logging."""

from typing import Optional
from qiskit.aqua import (QiskitLogDomains,
get_logging_level,
set_logging_level)


def get_qiskit_optimization_logging() -> int:
"""
Returns the current Qiskit Optimization logging level
Returns:
int: logging level
"""
return get_logging_level(QiskitLogDomains.DOMAIN_OPTIMIZATION)


def set_qiskit_optimization_logging(level: int, filepath: Optional[str] = None) -> None:
"""
Updates the Qiskit Optimization logging with the appropriate logging level
Args:
level: minimum severity of the messages that are displayed.
filepath: file to receive logging data
"""
set_logging_level(level, [QiskitLogDomains.DOMAIN_OPTIMIZATION], filepath)

0 comments on commit fbb69a9

Please sign in to comment.