Prior to existence of the global universe, the destination files for
logging may not be known. Accumulate log entries during
Universe.load() and then flush them once it's safe to do so.
filename = os.path.join(self.startdir, filename)
self.filename = filename
if load:
filename = os.path.join(self.startdir, filename)
self.filename = filename
if load:
+ # make sure to preserve any accumulated log entries during load
+ self.setup_loglines += self.load()
def load(self):
"""Load universe data from persistent storage."""
def load(self):
"""Load universe data from persistent storage."""
+ # it's possible for this to enter before logging configuration is read
+ pending_loglines = []
+
# the files dict must exist and filename needs to be read-only
if not hasattr(
self, "files"
# the files dict must exist and filename needs to be read-only
if not hasattr(
self, "files"
for element in self.contents.values():
element.update_location()
element.clean_contents()
for element in self.contents.values():
element.update_location()
element.clean_contents()
+ return pending_loglines
def new(self):
"""Create a new, empty Universe (the Big Bang)."""
def new(self):
"""Create a new, empty Universe (the Big Bang)."""
global universe
universe = Universe(conffile, True)
global universe
universe = Universe(conffile, True)
+ # report any loglines which accumulated during setup
+ for logline in universe.setup_loglines:
+ log(*logline)
+ universe.setup_loglines = []
+
# log an initial message
log("Started mudpy with command line: " + " ".join(sys.argv))
# log an initial message
log("Started mudpy with command line: " + " ".join(sys.argv))