• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: logLib - looking for feedback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: logLib - looking for feedback


  • Subject: Re: logLib - looking for feedback
  • From: email@hidden (Guillaume Iacino)
  • Date: Mon, 16 Sep 2002 09:48:52 -0700

Has,

Thank you for your detailed email.

I think I understand how your LogLib is supposed to work and I am definitely
trying to include it in mine :) Thanks.

I am still having the problem described in your [4]. My script creates
properly the file, logs messages and close it properly (I think).

Trying to test LogLib I did:

property logLib : load script (alias "content:LogTest2:logLib")
global normalLog

on run
set normalLog to logLib's newLog("content:LogTest2:testLog2")
tell normalLog
logTime()
logMsg("Task Completed")
closeLog()
tell logLib to disposeAllLogs() --[REQUIRED]
end tell
end run

Running twice the above script causes a message saying "Couldn't create new
log object [missing value]: Duplicate file name: FilePath"

This makes me wonder if I need first to check if the file exists and use
reopenLog() the second time around. But:

1. I have no idea on how to check if a file exists...
2. This is not what I understand from how LogLib is working, is it?

Also, is it possible to append two calls, doing something like:
logMsg(logTime() & "Task Completed") -- which fails

I am looking to log each entry into a single line. But I can definitely be
happy with the way it is now.

BTW: Is there a way to get the count of logs into the file?

Thank you.

Guillaume

On 9/13/02 20:15, "email@hidden"
<email@hidden> wrote:

> Message: 5
> Date: Fri, 13 Sep 2002 23:51:56 +0100
> To: email@hidden
> From: has <email@hidden>
> Subject: Re: logLib - looking for feedback
>
> 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.

  • Prev by Date: RE: OK, so who broke /usr/bin/AppleSystemProfiler?
  • Next by Date: Re: Lots of osaX
  • Previous by thread: Re: logLib - looking for feedback
  • Next by thread: iCal scripting?
  • Index(es):
    • Date
    • Thread