#129770 - 2004-11-19 10:59 AM
Re: Tracking/log system
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Come back when you're not so tired Jochen 
Reason to log to different log files is to eliminate file locking contention, ie. UDF for open file handles, potential long delays in logging waiting for file to close.
Easier to just let each system log their own log file, then copy all of them into a single file and import into Excel.
|
|
Top
|
|
|
|
#129774 - 2004-11-19 04:12 PM
Re: Tracking/log system
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Quote:
I'd claim that my suggestion could handle easily a few thousand accesses simultaneously (Which will never happen with anything as we all know)
That's enough ?
Are you sure? I was running into problems with just 30 users doing a writeprofilestring() once every 30 seconds to the same INI file. I ended going with a separate file for each user because the chances of collisions were too great.
Bryce
|
|
Top
|
|
|
|
#129776 - 2004-11-20 12:56 PM
Re: Tracking/log system
|
1984
Starting to like KiXtart
Registered: 2003-08-14
Posts: 150
|
Or mayby...
Based on maciep code, Jochen point and Docs comment....
Function LogIt($action)
$DTM = Join(Split(@date,"/"),"") $IPA = Join(Split(@IPADDRESS0,"."),"")
$LIG = $IPA+@userid
$WIP = @IPADDRESS0 $WUS = @USERID
$File = @USERID+".ini" $LogF = $DTM+'.ini' $Path = "\\Server\Share\ScriptDir\" $PNF = $Path+$File
If $action = ("Open")
$ = Open(1,$Path+$File,5) $ = WriteLine(1,"["+$LIG+"]"+@crlf) $ = WriteLine(1,"ID="+$WUS+@crlf) $ = WriteLine(1,"IP="+$WIP+@crlf) $ = WriteLine(1,"Opened="+@time+@crlf) $ = WriteLine(1,""+@crlf) $ = Close(1)
EndIf
If $action = ("Close")
$RIN = ReadProfileString($PNF,"","")
For Each $RINs in Split($RIN,Chr(10)) If $RINs
$RID = ReadProfileString($PNF,$RINs,"ID") $RIP = ReadProfileString($PNF,$RINs,"IP") $ROP = ReadProfileString($PNF,$RINs,"Opened") $RCL = ReadProfileString($PNF,$RINs,"Closed") If $RIP = $WIP AND $RID = $WUS $ = Open(1,$Path+$LogF,5) $ = WriteLine(1,"["+$RID+"]"+@crlf) $ = WriteLine(1,"IP="+$RIP+@crlf) $ = WriteLine(1,"Opened="+$ROP+@crlf) $ = WriteLine(1,"Closed="+@time+@crlf) $ = WriteLine(1,""+@crlf) $ = WriteProfileString($PNF,$RINs,$RCL,@time) $ = Close(1)
EndIf
EndFunction
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"
|
|
Top
|
|
|
|
#129777 - 2004-11-20 02:30 PM
Re: Tracking/log system
|
ChristopheM
Hey THIS is FUN
   
Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
|
Just a little remark about the last code.
If you use the file handle "1" in the function, you can have side effect if the calling code is using too the file handle "1".
In the function, you should use something like that : Code:
$handle = FreeFileHandle() $ = Open($handle,$Path+$File,5) $ = WriteLine($handle,"["+$LIG+"]"+@crlf) $ = WriteLine($handle,"ID="+$WUS+@crlf) $ = WriteLine($handle,"IP="+$WIP+@crlf) $ = WriteLine($handle,"Opened="+@time+@crlf) $ = WriteLine($handle,""+@crlf) $ = Close($handle)
this is safier.
_________________________
Christophe
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|