Add version command and diagnostic logging
[mudpy.git] / mudpy / misc.py
index 154b555..4355586 100644 (file)
@@ -335,6 +335,7 @@ class Universe:
         self.startdir = os.getcwd()
         self.terminate_flag = False
         self.userlist = []
+        self.versions = None
         if not filename:
             possible_filenames = [
                 "etc/mudpy.yaml",
@@ -2102,6 +2103,8 @@ def command_show(actor, parameters):
     arguments = parameters.split()
     if not parameters:
         message = "What do you want to show?"
+    elif arguments[0] == "version":
+        message = repr(universe.versions)
     elif arguments[0] == "time":
         message = universe.groups["internal"]["counters"].get(
             "elapsed"
@@ -2481,9 +2484,6 @@ def setup():
         log(*logline)
     universe.setup_loglines = []
 
-    # log an initial message
-    log("Started mudpy with command line: " + " ".join(sys.argv))
-
     # fork and disassociate
     daemonize(universe)
 
@@ -2496,6 +2496,17 @@ def setup():
     # make the pidfile
     create_pidfile(universe)
 
+    # load and store diagnostic info
+    universe.versions = mudpy.version.Versions("mudpy")
+
+    # log startup diagnostic messages
+    log("On %s at %s" % (universe.versions.python_version, sys.executable), 1)
+    log("Import path: %s" % ", ".join(sys.path), 1)
+    log("Installed dependencies: %s" % universe.versions.dependencies_text, 1)
+    log("Other python packages: %s" % universe.versions.environment_text, 1)
+    log("Started %s with command line: %s" % (
+        universe.versions.version, " ".join(sys.argv)), 1)
+
     # pass the initialized universe back
     return universe