Further improvement of log conditional

This commit is contained in:
Griatch 2022-02-14 00:34:13 +01:00
parent 39368bc9ae
commit 4e2962fef8
5 changed files with 17 additions and 17 deletions

View file

@ -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

View file

@ -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"

View file

@ -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),

View file

@ -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),

View file

@ -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)