Skip to content

Commit 22c5b05

Browse files
authored
Fix logging (#2199)
* fix atlas logging * replace some print statements with logging * typo
1 parent 6640787 commit 22c5b05

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

arcade/sound.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from __future__ import annotations
66

7+
import logging
78
import math
89
import os
910
from pathlib import Path
@@ -24,6 +25,8 @@
2425

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

28+
logger = logging.getLogger("arcade")
29+
2730

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

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

221224

arcade/sprite/animated.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import bisect
4+
import logging
45
import math
56
from typing import Optional
67

@@ -14,6 +15,8 @@
1415
)
1516
from .sprite import Sprite
1617

18+
logger = logging.getLogger("arcade")
19+
1720

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

336339
if self._texture is None:
337-
print("Error, no texture set")
340+
logger.warn("Error, no texture set")
338341
else:
339342
self.width = self._texture.width * self.scale_x
340343
self.height = self._texture.height * self.scale_x

arcade/texture_atlas/atlas_default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# texture anyway, so more rows can be added.
4545
UV_TEXTURE_WIDTH = 4096
4646

47-
LOG = logging.getLogger("atlas")
47+
LOG = logging.getLogger(__name__)
4848
# LOG.handlers = [logging.StreamHandler()]
4949
# LOG.setLevel(logging.INFO)
5050

0 commit comments

Comments
 (0)