Page 1 of 1

getting the log path on the client

Posted: Wed Nov 24, 2010 10:06 am
by ghosttie
I want to log some information to the client's log directory. Is this the right way to do it?

Code: Select all

getLogPathClient() : String; vars sLogPath : String; begin sLogPath := getProfileString(getIniFileName, "JadeLog", "LogDirectory", "<default>"); if sLogPath.toLower = "<default>" then sLogPath := process.getJadeHomeDirectory.ensureTrailingSlash & "logs\"; elseif sLogPath[1:2] <> "\\" and sLogPath[2:1] <> ":" then // relative path sLogPath := process.getJadeHomeDirectory.ensureTrailingSlash & sLogPath; endif; return sLogPath.ensureTrailingSlash; end;
ensureTrailingSlash is a method on String that just appends a slash if there isn't one there already.

Re: getting the log path on the client

Posted: Wed Nov 24, 2010 10:17 am
by BeeJay
From a quick scan of the code it looks like a reasonable start.

You'd probably want to add clientExecution to the method signature though, in case you're ever calling this from a serverExecution method. ;)

Cheers,
BeeJay.

Re: getting the log path on the client

Posted: Wed Nov 24, 2010 10:21 am
by ghosttie
Thanks. I wasn't clear on what base path a relative path should be appended to - getJadeHomeDirectory or getUserDataDirectory - and whether it should be the one from the process or node...

Re: getting the log path on the client

Posted: Wed Nov 24, 2010 10:32 am
by BeeJay
Ah, you're referring to a thin client, rather than a standard client - I should have deduced that with your sample code having Process::getJadeHomeDirectory not Node::getJadeHomeDirectory. I was going to add that you could use the JadeLog::infoClient etc methods and let JADE take care of working out the "logs" directory for you when you're running a standard client.

Note: It would be nice if NFS 33128 was implemented. Then you'd be able to avoid all this complexity by using the JadeLog class with JadeLog::infoThinClient etc methods and let Jade take care of working out the "logs" directory on the thin client for you.

Cheers,
BeeJay.

Re: getting the log path on the client

Posted: Wed Nov 24, 2010 11:32 am
by ghosttie
So do you think it's correct to use the Home Directory instead of the User Directory on a thin client?

Re: getting the log path on the client

Posted: Wed Nov 24, 2010 2:19 pm
by BeeJay
It all depends on where your thin client is installed to and what you are wanting to achieve.

If your thin client is installed into the Windows "Program Files" folder, and you want each user to have their own copy of the "logfile" then you would use getUserDataDirectory.

If your thin client is installed into the Windows "Program Files" folder, and you want all users to share one copy of the "logfile" then you would use getProgramDataDirectory.

If your thin client is not installed into the Windows "Program Files" folder, then it probably doesn't matter which of these you use as it would appear that they both default back to JADE HOME directory anyway, at least that's what the JADE doco says.

Note: I haven't tested any of this out programmatically, I'm just going by what the JADE documentation has to say in this regard. ;)

Cheers,
BeeJay.

Re: getting the log path on the client

Posted: Thu Nov 25, 2010 2:23 am
by ghosttie
OK, it sounds like getUserDataDirectory is the right choice because it returns the same as getJadeHomeDirectory unless JADE is installed in program files, in which case it returns the user data directory. This is what we want because we don't want to try to log to program files because we won't have permission as of Vista.

node.getUserDataDirectory seems to return a path on the server and process.getUserDataDirectory returns a path on the client.