From eecae7d240916774df48fc6fcf340fed86e3bb74 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 30 Dec 2019 01:49:32 +0000 Subject: [PATCH] Preserve loglines on reload When a reload occurs, prepend the new universe's loglines with those from the old universe so they are not lost. This may temporarily bloat the loglines list slightly over the limit, but it will be adjusted downward the next time anything new gets logged. Also adjust the `show log` selftests to handle linewraps in a new place when the total loglines count is higher. --- mudpy/misc.py | 3 +++ mudpy/tests/selftest.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mudpy/misc.py b/mudpy/misc.py index 5beb3b6..ec331a4 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -1436,9 +1436,12 @@ def reload_data(): """Reload all relevant objects.""" universe.save() old_userlist = universe.userlist[:] + old_loglines = universe.loglines[:] for element in list(universe.contents.values()): element.destroy() universe.load() + new_loglines = universe.loglines[:] + universe.loglines = old_loglines + new_loglines for user in old_userlist: user.reload() diff --git a/mudpy/tests/selftest.py b/mudpy/tests/selftest.py index d9a6ee0..f68f042 100644 --- a/mudpy/tests/selftest.py +++ b/mudpy/tests/selftest.py @@ -347,14 +347,14 @@ test_show_result = ( test_show_log = ( (2, "> ", "show log"), (2, r"There are [0-9]+ log lines in memory and [0-9]+ at or above level " - r"[0-9]+\. The matching lines\r\nfrom [0-9]+ to [0-9]+ are:", ""), + r"[0-9]+\. The matching.*from [0-9]+ to [0-9]+ are:", ""), ) test_custom_loglevel = ( (2, "> ", "set account.admin loglevel 2"), (2, "You have successfully .*> ", "show log"), (2, r"There are [0-9]+ log lines in memory and [0-9]+ at or above level " - r"[0-9]+\. The matching lines\r\nfrom [0-9]+ to [0-9]+ are:", ""), + r"[0-9]+\. The matching.*from [0-9]+ to [0-9]+ are:", ""), ) test_invalid_loglevel = ( -- 2.11.0