Skip to content

Commit

Permalink
Fix logging (#2199)
Browse files Browse the repository at this point in the history
* fix atlas logging

* replace some print statements with logging

* typo
  • Loading branch information
DigiDuncan authored Jul 3, 2024
1 parent 6640787 commit 22c5b05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions arcade/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from __future__ import annotations

import logging
import math
import os
from pathlib import Path
Expand All @@ -24,6 +25,8 @@

__all__ = ["Sound", "load_sound", "play_sound", "stop_sound"]

logger = logging.getLogger("arcade")


class Sound:
"""This class represents a sound you can play."""
Expand Down Expand Up @@ -202,7 +205,7 @@ def play_sound(
:param speed: Change the speed of the sound which also changes pitch, default 1.0
"""
if sound is None:
print("Unable to play sound, no data passed in.")
logger.warning("Unable to play sound, no data passed in.")
return None

elif not isinstance(sound, Sound):
Expand All @@ -215,7 +218,7 @@ def play_sound(
try:
return sound.play(volume, pan, loop, speed)
except Exception as ex:
print("Error playing sound.", ex)
logger.warn("Error playing sound.", ex)
return None


Expand Down
5 changes: 4 additions & 1 deletion arcade/sprite/animated.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import bisect
import logging
import math
from typing import Optional

Expand All @@ -14,6 +15,8 @@
)
from .sprite import Sprite

logger = logging.getLogger("arcade")


class TextureKeyframe:
"""
Expand Down Expand Up @@ -334,7 +337,7 @@ def update_animation(self, delta_time: float = 1 / 60) -> None:
self.texture = texture_list[self.cur_texture_index]

if self._texture is None:
print("Error, no texture set")
logger.warn("Error, no texture set")
else:
self.width = self._texture.width * self.scale_x
self.height = self._texture.height * self.scale_x
2 changes: 1 addition & 1 deletion arcade/texture_atlas/atlas_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# texture anyway, so more rows can be added.
UV_TEXTURE_WIDTH = 4096

LOG = logging.getLogger("atlas")
LOG = logging.getLogger(__name__)
# LOG.handlers = [logging.StreamHandler()]
# LOG.setLevel(logging.INFO)

Expand Down

0 comments on commit 22c5b05

Please sign in to comment.