Thanks,
done.
extract:
Code: Select all
;Europe=0
;Americas=1
#region=0
#am=0
#pm=3600*12
CompilerIf #region=0
datimask="%dd.%mm.%yyyy %hh:%ii:%ss"
region="EMEA"
CompilerElse
datimask="%mm/%dd/%yyyy %hh:%ii:%ss"
region="US"
CompilerEndIf
Procedure.s MyFormatDate(datim.l)
temp.s
result.s
CompilerIf #region=0
result=FormatDate(datimask,datim)
CompilerEndIf
CompilerIf #region=1
result=FormatDate(datimask,datim)
temp=Left(StringField(result,2," "),2)
If Val(temp)>12
datim-#pm
result=FormatDate(datimask,datim)+" PM"
Else
result+" AM"
EndIf
CompilerEndIf
ProcedureReturn result
EndProcedure
Procedure scanrec(orec.s)
line.s
field.s
value.s
datim.s
ampm.s
info.s
AddElement(alrec())
If ReadFile(0,orec)
Repeat
line=ReadString()
field=Trim(ReplaceString(StringField(line,1,":"),Chr(9)," ",1))
Select field
Case "Priority"
alrec()\priority=Trim(ReplaceString(StringField(line,2,":"),Chr(9)," ",1))
Case "Message"
CompilerIf #region=0
datim=StringField(line,2," ")+" "+Left(StringField(line,3," "),8)
alrec()\timestamp=ParseDate(datimask,datim)
alrec()\info=StringField(line,2,"]")
alrec()\message=StringField(line,12," ")
If alrec()\message="the"
alrec()\message="EICAR.test.virus"
EndIf
CompilerEndIf
CompilerIf #region=1
datim=StringField(line,2," ")+" "+Left(StringField(line,3," "),8)
ampm=Left(StringField(line,4," "),2)
alrec()\timestamp=ParseDate(datimask,datim)
If ampm="PM"
alrec()\timestamp+#pm
EndIf
alrec()\info=StringField(line,2,"]")
alrec()\message=StringField(line,14," ")
If alrec()\message="the"
alrec()\message="EICAR.test.virus"
EndIf
CompilerEndIf
Case "From"
alrec()\from=StringField(Trim(ReplaceString(StringField(line,2,":"),Chr(9)," ",1)),1,".")
EndSelect
Until Eof(0)<>0
CloseFile(0)
EndIf
EndProcedure
This works for me, cause the US version will always run on a US server, the EMEA version on a german server.
scanrec reads logfiles with a fixed format, that I can't change and fills a linked list.
This List us used to create a table and then a HTML file.
MyFormatDate is used to convert the date back to a string.
Michael
P.S:
I didn't post the complete code, cause without the server and the log files and the other html and idc/htx scripts around it, it doesn't make sense.
Since the server is company internal, I can't post a link.