class - Converting datetime string to integer (seconds ) then adding ms -


I am writing a program that essentially pulls out of a logfile, parse it, and parsed it Returns the data back to simplified form My main problem is currently this method in which I should parse the emotion that runs from time to time. Here is an example of a line from the log

Example of the logfile:

  2012-06-12 14: 02: 16,341 [main] info --- 2012 -06-12 14: 02: 16,50 9 [Chief] Information --- 2012-06-12 14: 02: 17,000 [Chief] Information --- 2012-06-12 14: 02: 17,112 [Main ] Information --- 2012-06-12 14: 02: 20,338 [Main] INFO --- 2012-06-12 14: 02: 21,813 [Main] INFO ---  < My code for parsing SO FAR (very difficult):  
  class logline: SEVERITIES = ['EMERG', 'ALERT', 'CRIT', 'ERR ',' Warning ',' Notice ',' INFO ',' debug '] Intensity = 1 def __init __ (self, line): Try: Mr. S, Swynfail name, N, themselves. Message = again Match ("^ (\ d \ d \ d \ d- \ d \ d- \ d \ d [\ t] \ d \ d: \ d \ d: \ d \ d, \ d \ d \ d) , Line) self.line = int (n) self.sev = self.severities.index (s) self.time = return def get_filename (self): return def get_line (self): return   

So basically (if you were not able to remove it from my awesome code) I'm parse string using a regular expression to parse e day-time I also form it as a possible solution In fact, reading about strtime is actually, I have to spend the time in milliseconds Need to C and then it will add to the millisecond integer Dettaim (separated by commas)

I'm sure this question is very complex and I ask before forgiveness. thanks for your cooperation.

  & gt; & Gt; & Gt; Datetime.datetime.strptime ('2012-06-12 14: 02: 16,341' + '000', '% Y-% m-% d% H:% M:% S,% f') datetime.datetime (2012 ), 6, 12, 14, 2, 16, 341000)    

Comments