Thread Subject: Diary quirkyness

Subject: Diary quirkyness

From: Todd Welti

Date: 11 Mar, 2009 23:59:02

Message: 1 of 5

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...?

Subject: Diary quirkyness

From: Steven Lord

Date: 12 Mar, 2009 14:11:56

Message: 2 of 5


"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

Subject: Diary quirkyness

From: Rune Allnor

Date: 12 Mar, 2009 17:09:17

Message: 3 of 5

On 12 Mar, 00:59, "Todd Welti" <twe...@harman.com> wrote:
> I have some code that uses "diary" near the start to make a log file.

You should be a bit carful about this. Things might have
changed since then, but ten years ago, DIARY logged what
went on in the command window. So anything that was not
entered or displayed in the command window (like using F5
to run a program from the editor window) was just missing
from the diary file.

Rune

Subject: Diary quirkyness

From: Todd Welti

Date: 12 Mar, 2009 17:20:22

Message: 4 of 5

Rune Allnor <allnor@tele.ntnu.no> wrote in message <43679d96-bbe2-4432-973b-673b2a88d7e3@e38g2000yqa.googlegroups.com>...
> On 12 Mar, 00:59, "Todd Welti" <twe...@harman.com> wrote:
> > I have some code that uses "diary" near the start to make a log file.
>
> You should be a bit carful about this. Things might have
> changed since then, but ten years ago, DIARY logged what
> went on in the command window. So anything that was not
> entered or displayed in the command window (like using F5
> to run a program from the editor window) was just missing
> from the diary file.
>
> Rune
I tried to account for this by controlling the diary entry in the m file code itself (deleting existing diary file, starting new one and stopping diary at the end of the m file) . But your point is still well taken.

Subject: Diary quirkyness

From: Rune Allnor

Date: 12 Mar, 2009 20:39:34

Message: 5 of 5

On 12 Mar, 18:20, "Todd Welti" <twe...@harman.com> wrote:
> Rune Allnor <all...@tele.ntnu.no> wrote in message <43679d96-bbe2-4432-97=
3b-673b2a88d...@e38g2000yqa.googlegroups.com>...
> > On 12 Mar, 00:59, "Todd Welti" <twe...@harman.com> wrote:
> > > I have some code that uses "diary" near the start to make a log file.
>
> > You should be a bit carful about this. Things might have
> > changed since then, but ten years ago, DIARY logged what
> > went on in the command window. So anything that was not
> > entered or displayed in the command window (like using F5
> > to run a program from the editor window) was just missing
> > from the diary file.
>
> > Rune
>
> I tried to account for this by controlling the diary entry in the m file =
code itself (deleting existing diary file, starting new one and stopping di=
ary at the end of the m file) . =A0But your point is still well taken.

If you have one .m file that deletes a present diary file,
and starts a new one, the diary file will be empty if
nothing was communicated back and forth to the command window.
With this approach, the diary file might at most contain
any warnings, error messages or program output.

Again, you need to be very careful about this, and make
sure you understand exactly how the diary works. As well
as being very pedantic about what functionality you want.

Rune

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
diary log file Todd Welti 11 Mar, 2009 20:00:26
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com