Further improvement of log conditional
This commit is contained in:
parent
39368bc9ae
commit
4e2962fef8
5 changed files with 17 additions and 17 deletions
|
|
@ -25,7 +25,6 @@ from evennia.utils.utils import (
|
||||||
format_grid,
|
format_grid,
|
||||||
)
|
)
|
||||||
from evennia.utils.eveditor import EvEditor
|
from evennia.utils.eveditor import EvEditor
|
||||||
from evennia.utils.evmenu import ask_yes_no
|
|
||||||
from evennia.utils.evmore import EvMore
|
from evennia.utils.evmore import EvMore
|
||||||
from evennia.utils.evtable import EvTable
|
from evennia.utils.evtable import EvTable
|
||||||
from evennia.prototypes import spawner, prototypes as protlib, menus as olc_menus
|
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 "
|
"by an explicit create_object call. Use `update` or type/force instead in order "
|
||||||
"to keep such data. "
|
"to keep such data. "
|
||||||
"Continue [Y]/N?|n")
|
"Continue [Y]/N?|n")
|
||||||
if answer.upper() == "N":
|
if answer.upper() in ("N", "NO"):
|
||||||
caller.msg("Aborted.")
|
caller.msg("Aborted.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1274,7 +1274,7 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
"Obj2 = evennia.objects.objects.DefaultExit",
|
"Obj2 = evennia.objects.objects.DefaultExit",
|
||||||
"Obj2 changed typeclass from evennia.objects.objects.DefaultObject "
|
"Obj2 changed typeclass from evennia.objects.objects.DefaultObject "
|
||||||
"to evennia.objects.objects.DefaultExit.",
|
"to evennia.objects.objects.DefaultExit.",
|
||||||
cmdstring="swap",
|
cmdstring="swap", inputs=["yes"],
|
||||||
)
|
)
|
||||||
self.call(building.CmdTypeclass(), "/list Obj", "Core typeclasses")
|
self.call(building.CmdTypeclass(), "/list Obj", "Core typeclasses")
|
||||||
self.call(
|
self.call(
|
||||||
|
|
@ -1302,7 +1302,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
building.CmdTypeclass(),
|
building.CmdTypeclass(),
|
||||||
"Obj",
|
"Obj",
|
||||||
"Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n"
|
"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",
|
cmdstring="update",
|
||||||
)
|
)
|
||||||
self.call(
|
self.call(
|
||||||
|
|
@ -1310,6 +1311,7 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
"/reset/force Obj=evennia.objects.objects.DefaultObject",
|
"/reset/force Obj=evennia.objects.objects.DefaultObject",
|
||||||
"Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n"
|
"Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n"
|
||||||
"All object creation hooks were run. All old attributes where deleted before the swap.",
|
"All object creation hooks were run. All old attributes where deleted before the swap.",
|
||||||
|
inputs=["yes"]
|
||||||
)
|
)
|
||||||
|
|
||||||
from evennia.prototypes.prototypes import homogenize_prototype
|
from evennia.prototypes.prototypes import homogenize_prototype
|
||||||
|
|
@ -1332,11 +1334,11 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdTypeclass(),
|
building.CmdTypeclass(),
|
||||||
"/prototype Obj=testkey",
|
"/prototype Obj=testkey",
|
||||||
"replaced_obj changed typeclass from "
|
"replaced_obj changed typeclass from evennia.objects.objects.DefaultObject to "
|
||||||
"evennia.objects.objects.DefaultObject to "
|
"typeclasses.objects.Object.\nOnly the at_object_creation hook was run "
|
||||||
"typeclasses.objects.Object.\nAll object creation hooks were "
|
"(update mode). Attributes set before swap were not removed\n"
|
||||||
"run. Attributes set before swap were not removed. Prototype "
|
"(use `swap` or `type/reset` to clear all). Prototype 'replaced_obj' was "
|
||||||
"'replaced_obj' was successfully applied over the object type.",
|
"successfully applied over the object type."
|
||||||
)
|
)
|
||||||
assert self.obj1.db.desc == "protdesc"
|
assert self.obj1.db.desc == "protdesc"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,9 +246,8 @@ class Portal(object):
|
||||||
application = service.Application("Portal")
|
application = service.Application("Portal")
|
||||||
|
|
||||||
|
|
||||||
if ("--nodaemon" not in sys.argv
|
if "--nodaemon" not in sys.argv and "test" not in sys.argv:
|
||||||
and not (hasattr(settings, "_TEST_ENVIRONMENT") and settings._TEST_ENVIRONMENT)):
|
# activate logging for interactive/testing mode
|
||||||
# custom logging
|
|
||||||
logfile = logger.WeeklyLogFile(
|
logfile = logger.WeeklyLogFile(
|
||||||
os.path.basename(settings.PORTAL_LOG_FILE),
|
os.path.basename(settings.PORTAL_LOG_FILE),
|
||||||
os.path.dirname(settings.PORTAL_LOG_FILE),
|
os.path.dirname(settings.PORTAL_LOG_FILE),
|
||||||
|
|
|
||||||
|
|
@ -647,9 +647,9 @@ except OperationalError:
|
||||||
# what to execute from.
|
# what to execute from.
|
||||||
application = service.Application("Evennia")
|
application = service.Application("Evennia")
|
||||||
|
|
||||||
if ("--nodaemon" not in sys.argv
|
|
||||||
and not (hasattr(settings, "_TEST_ENVIRONMENT") and settings._TEST_ENVIRONMENT)):
|
if "--nodaemon" not in sys.argv and "test" not in sys.argv:
|
||||||
# custom logging, but only if we are not running in interactive mode
|
# activate logging for interactive/testing mode
|
||||||
logfile = logger.WeeklyLogFile(
|
logfile = logger.WeeklyLogFile(
|
||||||
os.path.basename(settings.SERVER_LOG_FILE),
|
os.path.basename(settings.SERVER_LOG_FILE),
|
||||||
os.path.dirname(settings.SERVER_LOG_FILE),
|
os.path.dirname(settings.SERVER_LOG_FILE),
|
||||||
|
|
|
||||||
|
|
@ -206,11 +206,11 @@ class GetLogObserver:
|
||||||
event["log_system"] = self.event_levels.get(lvl, "-")
|
event["log_system"] = self.event_levels.get(lvl, "-")
|
||||||
event["log_format"] = str(event.get("log_format", ""))
|
event["log_format"] = str(event.get("log_format", ""))
|
||||||
component_prefix = self.component_prefix or ""
|
component_prefix = self.component_prefix or ""
|
||||||
|
log_msg = twisted_logger.formatEventAsClassicLogText(
|
||||||
return component_prefix + twisted_logger.formatEventAsClassicLogText(
|
|
||||||
event,
|
event,
|
||||||
formatTime=lambda e: twisted_logger.formatTime(e, _TIME_FORMAT)
|
formatTime=lambda e: twisted_logger.formatTime(e, _TIME_FORMAT)
|
||||||
)
|
)
|
||||||
|
return f"{component_prefix}{log_msg}"
|
||||||
|
|
||||||
def __call__(self, outfile):
|
def __call__(self, outfile):
|
||||||
return twisted_logger.FileLogObserver(outfile, self.format_log_event)
|
return twisted_logger.FileLogObserver(outfile, self.format_log_event)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue