Re: logLib - looking for feedback
Re: logLib - looking for feedback
- Subject: Re: logLib - looking for feedback
- From: has <email@hidden>
- Date: Fri, 13 Sep 2002 23:51:56 +0100
Hi,
>
This is a really cool widget that you built there. I am quite a newbie in
>
AppleScript and LogFile is exactly what I was looking for to incorporate
>
inside my script. Of course, I would have not been able to do it without
>
your script.
Cool [always my hope that others will find my stuff useful]. So you could
understand it okay then? I would take this as a positive sign. So far the
only person that I _know_ understands it is me - and I don't really count.;)
>
I do have aa question. Please excuse me if it is basic and more related to
>
AppleScript in general then your script.
>
>
>
*NewLog([file]) -- the file to write to; if no file exists, one will be
>
created.
>
Does it mean that if the file already exist, the file specified will be
>
opened the next time you use logMsg() or do I need to use reopenLog()?
>
In my tests if the file is already created: NewLog() fails.
Mmmm... I'll have another shot at the documentation later; I didn't think
it was clear enough yet.
LogLib is designed so that the file is opened automatically when the log
object is created [1]. The file stays open for access for the duration of
the session [2]. Once you've finished using the log object, you must tell
it to close the file; if you don't, the file will _stay_open_ even after
your script quits (until you restart Finder/system) [3]. To close your log
when done with it, you can either:
1. send a closeLog() message to the log object
2. send a disposeAllLogs() message to logLib itself.
(See manual for more details.) Try one of these first, if you haven't
already; it could just be that the file's been left open from last time. [4]
BTW, the reopenLog() call allows you to reopen a log previously closed by
closeLog(). This may be useful when you've got a stay-open script that only
uses the log periodically, and don't wish to hog the file when it's not in
use [5].
>
What I am looking to do is to create the file first and if it already exist,
>
add some logs with clearing the previous one.
You can clear a log file's contents using clearLog().
Please do let me know how you get on: any confusion it might cause,
problems you run into, stuff that hasn't been explained in the
documentation, etc. Being told about all the _bad_ things in a piece of
software really is the best feedback, and will help me improve the thing
and make it easier to use [6].
Many thanks,
has
--
[1] I'm wondering if this is a good approach or not. It might be better to
leave it to the user user to open the file with an explicit openLog() call.
[2] This is much faster than opening and closing the file for each write,
but isn't without its costs.
[3] One of the aforementioned costs.
[4] If this _isn't_ your problem, can you post back with a description of
the error message it gave you? (I don't have X.2 yet, so can't test it
there myself.)
[5] The other cost of the "file stays open" approach (as Steve A. has
kindly pointed out to me) is that users can't open the logfile in other
applications to view it while your script has it open. (Eventually I'll get
around to providing other file-access modes so that users can pick
whichever one suits them best. For now, I'm just trying out the trickiest
and most ambitious of the options to see how it fares in real use.)
[6] Also, I hope to use a similar pattern to create other sorts of file
read/write objects in future, but if this design causes users too much
trouble then I'll know not to [and will just have to look for some other
way].
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.