Index: branches/LCSv2/controllers/default.py
===================================================================
--- branches/LCSv2/controllers/default.py	(revision 626)
+++ branches/LCSv2/controllers/default.py	(revision 634)
@@ -1,7 +1,9 @@
 # added comments for testing
 # Constants
+kLogfile = "samplelogfile.txt"
+kSimtimefile = "sim_elapsedtime.json"
 hwys = ['','1','5', '22', '55', '57', '73', '74', '91', '133', '142', '241', '261', '405', '605']
 hwyDirections = ['','NB', 'SB', 'NB/SB','EB','WB','EB/WB']
-# Names to appeaer in the username dropdown box
+# Names to appear in the username dropdown box
 users = []
 # Show the login page
@@ -189,4 +191,9 @@
             fieldname = "s"+session.statustype[0:4]+"time"
             db(db.closures.closureid == session.statustype[4:]).update(**{fieldname:now.strftime("%H%M")})
+            # Log the update to external file
+            logmessage = getSimTime() + " LCS status update: " + session.username + ", " + session.statustype[4:] + ", " + session.statustype[0:4] + ", " + session.statuser + " " + "\n"
+            text_file = open(kLogfile, "a")
+            text_file.write(logmessage)
+            text_file.close()
         else:
             msg = "error because only checking one box is allowed."
@@ -201,4 +208,17 @@
     else:
         return ""
+
+# Fetch simulation time and format it into a timestamp
+def getSimTime():
+    import json,datetime
+    try:
+        jsontime = json.load(open(kSimtimefile,'r'))
+        currentSimTime = jsontime["elapsedtime"]
+        timestamp = str(datetime.timedelta(seconds = int(currentSimTime)))
+        return timestamp
+    except:
+        # Fallback if missing file, use current time 
+        now = datetime.datetime.today()
+        return now.strftime("%H:%M:%S")
 
 # Create a new record
@@ -296,4 +316,9 @@
         newrec = db.closures.insert(closureid=newID, lognum=newLognum, route=form.vars.route, direction=form.vars.direction, facility=form.vars.facility, startcounty=form.vars.startcounty, endcounty=form.vars.endcounty, startlocation=form.vars.startlocation, endlocation=form.vars.endlocation, startdate=form.vars.startdate, enddate=form.vars.enddate, starttime=form.vars.starttime+form.vars.starttimemin, endtime=form.vars.endtime+form.vars.endtimemin, closuretype=form.vars.closuretype, closedlanes=selectedlanes, worktype=form.vars.worktype, estdelay=form.vars.estdelay, tmpcozeep=getCheckbox(form.vars.cozeep), tmpdetour=getCheckbox(form.vars.detour), supervisor=supervisor_name, fieldrep=fieldrep_name, s1097date='', s1098date='', s1022date='' )
         session.flash = 'New lane closure added: ' + newID + ' ' + newLognum + ': ' + selectedlanes
+        # Log the new closure to external file. Username, closureID, route, dir, type of closure, type of work
+        logmessage = getSimTime() + " LCS new closure: " + session.username + ", " + newID + '.' + newLognum + ', ' + form.vars.route + form.vars.direction + ', ' + form.vars.closuretype + ', ' + form.vars.worktype + "\n"
+        text_file = open(kLogfile, "a")
+        text_file.write(logmessage)
+        text_file.close()
         redirect(URL('search.html'))
     return dict(form=form)
