Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/how-to/configure-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ BlueAPI is configured to handle logging from any python code it executes.

```
import logging
logger = logging.getLogger(__name__)
logger.info("FOO")
LOGGER = logging.getLogger(__name__)
LOGGER.info("FOO")
```

# Kubernetes
Expand Down
4 changes: 3 additions & 1 deletion src/blueapi/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
from .scratch import setup_scratch
from .updates import CliEventRenderer

LOGGER = logging.getLogger(__name__)


@click.group(
invoke_without_command=True, context_settings={"auto_envvar_prefix": "BLUEAPI"}
Expand Down Expand Up @@ -493,7 +495,7 @@ def logout(obj: dict) -> None:
except FileNotFoundError:
print("Logged out")
except ValueError as e:
logging.debug("Invalid login token: %s", e)
LOGGER.debug("Invalid login token: %s", e)
raise ClickException(
"Login token is not valid - remove before trying again"
) from e
Expand Down
12 changes: 7 additions & 5 deletions src/blueapi/cli/scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

_DEFAULT_INSTALL_TIMEOUT: float = 300.0

LOGGER = logging.getLogger(__name__)


def setup_scratch(
config: ScratchConfig, install_timeout: float = _DEFAULT_INSTALL_TIMEOUT
Expand All @@ -30,7 +32,7 @@ def setup_scratch(

_validate_root_directory(config.root, config.required_gid)

logging.info(f"Setting up scratch area: {config.root}")
LOGGER.info(f"Setting up scratch area: {config.root}")

""" fail early """
for repo in config.repositories:
Expand Down Expand Up @@ -64,12 +66,12 @@ def ensure_repo(remote_url: str, local_directory: Path) -> None:
os.umask(stat.S_IWOTH)

if not local_directory.exists():
logging.info(f"Cloning {remote_url}")
LOGGER.info(f"Cloning {remote_url}")
Repo.clone_from(remote_url, local_directory)
logging.info(f"Cloned {remote_url} -> {local_directory}")
LOGGER.info(f"Cloned {remote_url} -> {local_directory}")
elif local_directory.is_dir():
Repo(local_directory)
logging.info(f"Found {local_directory}")
LOGGER.info(f"Found {local_directory}")
else:
raise KeyError(
f"Unable to open {local_directory} as a git repository because it is a file"
Expand All @@ -90,7 +92,7 @@ def scratch_install(path: Path, timeout: float = _DEFAULT_INSTALL_TIMEOUT) -> No

_validate_directory(path)

logging.info(f"Installing {path}")
LOGGER.info(f"Installing {path}")
process = Popen(
[
"uv",
Expand Down
4 changes: 3 additions & 1 deletion src/blueapi/client/numtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from blueapi.utils import BlueapiBaseModel

LOGGER = logging.getLogger(__name__)


class DirectoryPath(BlueapiBaseModel):
"""
Expand Down Expand Up @@ -105,5 +107,5 @@ def create_scan(
raise RuntimeError(f"Numtracker error: {json['errors']}")

new_collection = NumtrackerScanMutationResponse.model_validate(json["data"])
logging.debug("New NumtrackerNewScan: %s", new_collection)
LOGGER.debug("New NumtrackerNewScan: %s", new_collection)
return new_collection
2 changes: 1 addition & 1 deletion src/blueapi/worker/task_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def submit_task(self, task: Task) -> str:
request_id = get_baggage("correlation_id")
# If request id is not a string, we do not pass it into a TrackableTask
if not isinstance(request_id, str):
logging.warning(f"Invalid correlation id detected: {request_id}")
LOGGER.warning(f"Invalid correlation id detected: {request_id}")
request_id = None
trackable_task = TrackableTask(
task_id=task_id,
Expand Down