b01e95110f02879f2c581743c81655b1011fb350
chmalee
  Tue Jul 21 16:52:34 2020 -0700
Fix bug in error log trimmer when munging two lines together

diff --git src/hg/logCrawl/dbTrackAndSearchUsage/trimTrackLogs src/hg/logCrawl/dbTrackAndSearchUsage/trimTrackLogs
index a1f6934..6226921 100755
--- src/hg/logCrawl/dbTrackAndSearchUsage/trimTrackLogs
+++ src/hg/logCrawl/dbTrackAndSearchUsage/trimTrackLogs
@@ -13,30 +13,34 @@
 def parseCommandLine():
     parser = argparse.ArgumentParser(description="", add_help=True, usage="%(prog)s [options]")
     parser.add_argument("infile", action="store", default=None, help="Input Apache error_log file, use 'stdin' to read from standard input")
     parser.add_argument("-v", "--verbose", action="store_true", default=False, help="Log verbose output to stderr")
     args = parser.parse_args()
     return args
 
 def addOrMergeUsage(date, pid, ip, logPart, db, hgsid, tracks):
     """Add a new usage onto the usageDict list, or add more tracks onto the end of a previous usage."""
     global useDict
     key = "|".join([pid,ip,hgsid])
     if logPart == 0:
         val = "|".join([date,db,tracks])
         useDict[key].append(val)
     else:
+        # be sure to add a comma in case apache failed to add a referer:
+        if useDict[key][-1][-1] != ",":
+            useDict[key][-1] += "," + tracks
+        else:
             useDict[key][-1] += tracks
 
 def processPrefix(line):
     """Split the apache error log parts between brackets into a list of elements."""
     ret = []
     current = ""
     for i in range(len(line)):
         c = line[i]
         if c == "]" or (not i != len(line) - 1 and current):
             # the 'AH01215:' before the trackLog statement, a relatively recent Apache addition
             if c != "]": 
                 current += c
             ret.append(current.strip())
             current = ""
         elif c == "[":