Skip to content

Serial (Link Cable) support #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Redefine logging levels to minimize noise and improve usability
  • Loading branch information
Baekalfen committed May 21, 2025
commit d3f7b6537aded7ed2933b5c236d8d020f962e639
2 changes: 1 addition & 1 deletion pyboy/core/cartridge/cartridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def load_romfile(filename):

logger.debug("Loading ROM file: %d bytes", len(romdata))
if len(romdata) == 0:
logger.error("ROM file is empty!")
logger.critical("ROM file is empty!")
raise PyBoyException("Empty ROM file")

banksize = 16 * 1024
Expand Down
2 changes: 1 addition & 1 deletion pyboy/core/cartridge/mbc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def setitem(self, address, value):
def getitem(self, address):
if 0xA000 <= address < 0xC000:
if not self.rambank_initialized:
logger.error("RAM banks not initialized: %0.4x", address)
logger.warning("RAM banks not initialized: %0.4x", address)

if not self.rambank_enabled:
return 0xFF
Expand Down
2 changes: 1 addition & 1 deletion pyboy/core/cartridge/mbc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def getitem(self, address):
return self.rombanks[self.rombank_selected, address - 0x4000]
elif 0xA000 <= address < 0xC000:
if not self.rambank_initialized:
logger.error("RAM banks not initialized: %0.4x", address)
logger.warning("RAM banks not initialized: %0.4x", address)

if not self.rambank_enabled:
return 0xFF
Expand Down
2 changes: 1 addition & 1 deletion pyboy/core/cartridge/rtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, filename):
self.halt = 0

if not os.path.exists(self.filename):
logger.info("No RTC file found. Skipping.")
logger.debug("No RTC file found. Skipping.")
else:
with open(self.filename, "rb") as f:
self.load_state(IntIOWrapper(f), STATE_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion pyboy/core/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
serial_interrupt_based=False,
):
if bootrom_file is not None:
logger.info("Boot-ROM file provided")
logger.debug("Boot-ROM file provided")

self.cartridge = cartridge.load_cartridge(gamerom)
logger.debug("Cartridge started:\n%s", str(self.cartridge))
Expand Down
2 changes: 1 addition & 1 deletion pyboy/core/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def sample(self):
right_sample = 0

if self.audiobuffer_head >= self.audiobuffer_length:
logger.critical("Buffer overrun! %d of %d", self.audiobuffer_head, self.audiobuffer_length)
logger.warning("Buffer overrun! %d of %d", self.audiobuffer_head, self.audiobuffer_length)
return
self.audiobuffer[self.audiobuffer_head] = left_sample
self.audiobuffer[self.audiobuffer_head + 1] = right_sample
Expand Down
12 changes: 6 additions & 6 deletions pyboy/logging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(
DEBUG,
INFO,
WARNING,
ERROR,
CRITICAL,
DEBUG, # Only for developers
WARNING, # Unexpected failure that can be worked around
ERROR, # Unexpected failure that impacts usability
CRITICAL, # Unexpected failure where we cannot continue
INFO, # Normal operation, that the user *needs* or *wants* to be aware of
) = range(5)

_log_level = WARNING
_log_level = INFO


def get_log_level():
Expand Down
14 changes: 7 additions & 7 deletions pyboy/pyboy.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def __init__(

for k, v in kwargs.items():
if k not in defaults and k not in plugin_manager_keywords:
logger.error("Unknown keyword argument: %s", k)
logger.critical("Unknown keyword argument: %s", k)
raise KeyError(f"Unknown keyword argument: {k}")

# Performance measures
Expand Down Expand Up @@ -616,7 +616,7 @@ def _pause(self):
self.paused = True
self.save_target_emulationspeed = self.target_emulationspeed
self.target_emulationspeed = 1
logger.info("Emulation paused!")
logger.debug("Emulation paused!")
self._update_window_title()
self._plugin_manager.paused(True)

Expand All @@ -625,7 +625,7 @@ def _unpause(self):
return
self.paused = False
self.target_emulationspeed = self.save_target_emulationspeed
logger.info("Emulation unpaused!")
logger.debug("Emulation unpaused!")
self._update_window_title()
self._plugin_manager.paused(False)

Expand Down Expand Up @@ -683,9 +683,9 @@ def stop(self, save=True):
provided game-ROM.
"""
if self.initialized and not self.stopped:
logger.info("###########################")
logger.info("# Emulator is turning off #")
logger.info("###########################")
logger.debug("###########################")
logger.debug("# Emulator is turning off #")
logger.debug("###########################")
self._plugin_manager.stop()
self.mb.stop(save)
self.stopped = True
Expand Down Expand Up @@ -1125,7 +1125,7 @@ def _load_symbols(self):
gamerom_file_no_ext, rom_ext = os.path.splitext(self.gamerom)
for sym_path in [self.symbols_file, gamerom_file_no_ext + ".sym", gamerom_file_no_ext + rom_ext + ".sym"]:
if sym_path and os.path.isfile(sym_path):
logger.info("Loading symbol file: %s", sym_path)
logger.debug("Loading symbol file: %s", sym_path)
with open(sym_path) as f:
for _line in f.readlines():
line = _line.strip()
Expand Down