Skip to content

Commit

Permalink
Few small changes to log support (#73)
Browse files Browse the repository at this point in the history
* display only last n lines of the log

* change mod path to mod name in log file

* add log to install cmd
  • Loading branch information
duran55 authored Dec 21, 2024
1 parent b930e02 commit dcf297a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ammo/controller/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,11 @@ def do_log(self) -> None:
Show debug log history.
"""
_log = ""
n = 30
if self.game.ammo_log.exists():
with open(self.game.ammo_log, "r") as f:
_log = f.read()
lines = f.readlines()
_log = ''.join(lines[-min(len(lines), n):])

raise Warning(_log)

Expand Down Expand Up @@ -686,7 +688,8 @@ def do_rename_mod(self, index: int, name: str) -> None:
self.clean_game_dir()

# Move the folder, update the mod.
log.info(f"Renaming MOD {mod.location} to {new_location}")
log.info(f"Renaming MOD {mod.name} to {name}")

mod.location.rename(new_location)
mod.location = new_location
mod.name = name
Expand Down Expand Up @@ -724,7 +727,7 @@ def do_delete_mod(self, index: Union[int, str]) -> None:
self.set_mod_state(self.mods.index(target_mod), False)
self.mods.remove(target_mod)
try:
log.info(f"Deleting MOD: {target_mod.location}")
log.info(f"Deleting MOD: {target_mod.name}")
shutil.rmtree(target_mod.location)
except FileNotFoundError:
pass
Expand All @@ -746,7 +749,7 @@ def do_delete_mod(self, index: Union[int, str]) -> None:
self.set_mod_state(self.mods.index(target_mod), False)
self.mods.pop(index)
try:
log.info(f"Deleting MOD: {target_mod.location}")
log.info(f"Deleting MOD: {target_mod.name}")
shutil.rmtree(target_mod.location)
except FileNotFoundError:
pass
Expand Down Expand Up @@ -798,6 +801,7 @@ def do_install(self, index: Union[int, str]) -> None:
raise Warning(e)

def install_download(index, download) -> None:
log.info(f"Installing archive: {download.name}")
extract_to = "".join(
[
i
Expand Down

0 comments on commit dcf297a

Please sign in to comment.