-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from BQSKit/runtime-updates
Runtime updates
- Loading branch information
Showing
29 changed files
with
1,167 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""This module contains the logging configuration and methods for BQSKit.""" | ||
from __future__ import annotations | ||
|
||
import logging | ||
from sys import stdout as _stdout | ||
|
||
|
||
_logging_initialized = False | ||
|
||
|
||
def enable_logging(verbose: bool = False) -> None: | ||
""" | ||
Enable logging for BQSKit. | ||
Args: | ||
verbose (bool): If set to True, will print more verbose messages. | ||
Defaults to False. | ||
""" | ||
global _logging_initialized | ||
if not _logging_initialized: | ||
_logger = logging.getLogger('bqskit') | ||
_handler = logging.StreamHandler(_stdout) | ||
_handler.setLevel(0) | ||
_fmt_header = '%(asctime)s.%(msecs)03d - %(levelname)-8s |' | ||
_fmt_message = ' %(name)s: %(message)s' | ||
_fmt = _fmt_header + _fmt_message | ||
_formatter = logging.Formatter(_fmt, '%H:%M:%S') | ||
_handler.setFormatter(_formatter) | ||
_logger.addHandler(_handler) | ||
_logging_initialized = True | ||
|
||
level = logging.DEBUG if verbose else logging.INFO | ||
logging.getLogger('bqskit').setLevel(level) | ||
|
||
|
||
def disable_logging() -> None: | ||
"""Disable logging for BQSKit.""" | ||
logging.getLogger('bqskit').setLevel(logging.CRITICAL) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.