Page 2 of 2 <12
Topic Options
#129770 - 2004-11-19 10:59 AM Re: Tracking/log system
NTDOC Administrator Offline
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
#129771 - 2004-11-19 11:09 AM Re: Tracking/log system
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Sorry Ron,

I don't think so.
The only reason to get a current usage state for 1984, as I read it, is to be sure that noone has it actually running when he wants to update the thing.
So there speaks nothing against using a single ini-file
_________________________



Top
#129772 - 2004-11-19 11:30 AM Re: Tracking/log system
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hmmm... perhaps. I agree not as bad as every user and every logon it doesn't sound like, but he also did not say how many users and how often he thinks the logging would happen. If it were hundreds or thousands of times then I would not opt for single, but if only a few users at random times then yes I agree with you that a single central .INI would be the best method.
Top
#129773 - 2004-11-19 11:42 AM Re: Tracking/log system
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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 ?


Edited by Jochen (2004-11-19 11:45 AM)
_________________________



Top
#129774 - 2004-11-19 04:12 PM Re: Tracking/log system
Bryce Offline
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
#129775 - 2004-11-19 07:12 PM Re: Tracking/log system
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Another prob with INI files is that the APIs do not return @Error so if the logging is important, one has to do a read after write verify. Another thing with INI files is that the entire file gets read into memory which may or may not be trivial. Individual INI files as what DOC proposes with flat text files can also be merged into a CSV with an admin script.

INI files are better suited to store changing data while avoiding dups.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#129776 - 2004-11-20 12:56 PM Re: Tracking/log system
1984 Offline
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 Offline
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
#129778 - 2004-11-20 07:35 PM Re: Tracking/log system
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Good point Bryce, but I think this doesn't matter in this case.

I see the form writing only TWICE to the ini file; once it starts it writes the time value to @wksta key (workstationname=@time), and when the form is closed it just deletes the key.
So how often will it happen that only 10 Users open or close the form at the same time ?
See? No problem


_________________________



Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.063 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org