Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Diary quirkyness
Date: Thu, 12 Mar 2009 10:11:56 -0400
Organization: The MathWorks, Inc.
Lines: 31
Message-ID: <gpb579$mhc$1@fred.mathworks.com>
References: <gp9j86$i4r$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1236867113 23084 144.212.105.187 (12 Mar 2009 14:11:53 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 12 Mar 2009 14:11:53 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:524335



"Todd Welti" <twelti@harman.com> wrote in message 
news:gp9j86$i4r$1@fred.mathworks.com...
>I have some code that uses "diary" near the start to make a log file.  I 
>had checked it early on and it seemed to work fine.  now though i notice 
>that sometimes the file is empty, if the code encounters errors and quits. 
>Does diary wait until its associated mfile is finished to write to the 
>diary file?  I tested this by putting in a breakpoint after the diary file 
>was created and some text was displayed in the console, but before the main 
>mfile had finished.  i saw the diary .txt file, but nothing in it.  perhaps 
>it slows down execution if each text line in the console is written to the 
>diary file realitme.  Perhaps there is a buffer...?

Try one of these two things:

1) Create an onCleanup object whose cleanup function closes the diary.  I 
don't know if this will work if MATLAB crashes and terminates immediately, 
but it will close the diary if your function exits [thereby causing the 
onCleanup object to go out of scope.]

2) Start MATLAB with the -logfile startup option.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f8-4994.html

I believe that doesn't buffer the same way DIARY does.

-- 
Steve Lord
slord@mathworks.com