diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 81fd1d4076..d82bcd173d 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -25,7 +25,6 @@ from evennia.utils.utils import ( format_grid, ) from evennia.utils.eveditor import EvEditor -from evennia.utils.evmenu import ask_yes_no from evennia.utils.evmore import EvMore from evennia.utils.evtable import EvTable from evennia.prototypes import spawner, prototypes as protlib, menus as olc_menus @@ -2225,7 +2224,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS): "by an explicit create_object call. Use `update` or type/force instead in order " "to keep such data. " "Continue [Y]/N?|n") - if answer.upper() == "N": + if answer.upper() in ("N", "NO"): caller.msg("Aborted.") return diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index b21b504e60..79f800b0e4 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -1274,7 +1274,7 @@ class TestBuilding(BaseEvenniaCommandTest): "Obj2 = evennia.objects.objects.DefaultExit", "Obj2 changed typeclass from evennia.objects.objects.DefaultObject " "to evennia.objects.objects.DefaultExit.", - cmdstring="swap", + cmdstring="swap", inputs=["yes"], ) self.call(building.CmdTypeclass(), "/list Obj", "Core typeclasses") self.call( @@ -1302,7 +1302,8 @@ class TestBuilding(BaseEvenniaCommandTest): building.CmdTypeclass(), "Obj", "Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n" - "Only the at_object_creation hook was run (update mode). Attributes set before swap were not removed.", + "Only the at_object_creation hook was run (update mode). Attributes set before swap were not removed\n" + "(use `swap` or `type/reset` to clear all).", cmdstring="update", ) self.call( @@ -1310,6 +1311,7 @@ class TestBuilding(BaseEvenniaCommandTest): "/reset/force Obj=evennia.objects.objects.DefaultObject", "Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n" "All object creation hooks were run. All old attributes where deleted before the swap.", + inputs=["yes"] ) from evennia.prototypes.prototypes import homogenize_prototype @@ -1332,11 +1334,11 @@ class TestBuilding(BaseEvenniaCommandTest): self.call( building.CmdTypeclass(), "/prototype Obj=testkey", - "replaced_obj changed typeclass from " - "evennia.objects.objects.DefaultObject to " - "typeclasses.objects.Object.\nAll object creation hooks were " - "run. Attributes set before swap were not removed. Prototype " - "'replaced_obj' was successfully applied over the object type.", + "replaced_obj changed typeclass from evennia.objects.objects.DefaultObject to " + "typeclasses.objects.Object.\nOnly the at_object_creation hook was run " + "(update mode). Attributes set before swap were not removed\n" + "(use `swap` or `type/reset` to clear all). Prototype 'replaced_obj' was " + "successfully applied over the object type." ) assert self.obj1.db.desc == "protdesc" diff --git a/evennia/server/portal/portal.py b/evennia/server/portal/portal.py index fd23d2a938..e52456e37b 100644 --- a/evennia/server/portal/portal.py +++ b/evennia/server/portal/portal.py @@ -246,9 +246,8 @@ class Portal(object): application = service.Application("Portal") -if ("--nodaemon" not in sys.argv - and not (hasattr(settings, "_TEST_ENVIRONMENT") and settings._TEST_ENVIRONMENT)): - # custom logging +if "--nodaemon" not in sys.argv and "test" not in sys.argv: + # activate logging for interactive/testing mode logfile = logger.WeeklyLogFile( os.path.basename(settings.PORTAL_LOG_FILE), os.path.dirname(settings.PORTAL_LOG_FILE), diff --git a/evennia/server/server.py b/evennia/server/server.py index a9309b8418..4f653ffad5 100644 --- a/evennia/server/server.py +++ b/evennia/server/server.py @@ -647,9 +647,9 @@ except OperationalError: # what to execute from. application = service.Application("Evennia") -if ("--nodaemon" not in sys.argv - and not (hasattr(settings, "_TEST_ENVIRONMENT") and settings._TEST_ENVIRONMENT)): - # custom logging, but only if we are not running in interactive mode + +if "--nodaemon" not in sys.argv and "test" not in sys.argv: + # activate logging for interactive/testing mode logfile = logger.WeeklyLogFile( os.path.basename(settings.SERVER_LOG_FILE), os.path.dirname(settings.SERVER_LOG_FILE), diff --git a/evennia/utils/logger.py b/evennia/utils/logger.py index 18d8d0047c..ea0728a501 100644 --- a/evennia/utils/logger.py +++ b/evennia/utils/logger.py @@ -206,11 +206,11 @@ class GetLogObserver: event["log_system"] = self.event_levels.get(lvl, "-") event["log_format"] = str(event.get("log_format", "")) component_prefix = self.component_prefix or "" - - return component_prefix + twisted_logger.formatEventAsClassicLogText( + log_msg = twisted_logger.formatEventAsClassicLogText( event, formatTime=lambda e: twisted_logger.formatTime(e, _TIME_FORMAT) ) + return f"{component_prefix}{log_msg}" def __call__(self, outfile): return twisted_logger.FileLogObserver(outfile, self.format_log_event)