Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #807
| From | James Waldby <not@valid.invalid> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: How to implement diagnostic messages? |
| Date | 2011-09-10 00:17 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <j4eab1$gaq$1@dont-email.me> (permalink) |
| References | <4e68c9ed$0$31290$a729d347@news.telepac.pt> |
On Thu, 08 Sep 2011 14:58:05 +0100, Rui Maciel wrote: > In some applications it's useful to have, at least in the development > stages, a way to output diagnostic messages in order to help developers > check what's happening under the hood. Yet, although this can be useful > and in some times even invaluable, there isn't much information on what > are considered to be good practices regarding the implementation of > diagnostic messages. > > With this in mind, what are your views on how to implement diagnostic > messages? Are simple outputs to stderr enough or are there better ways > to handle this? During development of complex code in C, I add (and later remove) many ephemeral printf's. If it seems probable that I might want to reinstate a printf later, I might comment it out, or preface it by if(0), or save a versioned copy. On those rare occasions where I'm trying to find the point in the program where a seg-fault or similar problem is occurring, I add the letter z at the fronts of several lines, where z invokes a macro defined as follows: #define z fprintf(stderr,"%s@%3d \n",__FILE__,__LINE__); Then a few program runs, with z's added or removed as necessary, will serve to pinpoint the error. It sometimes is necessary to add if() conditions before the fprintf(), or add critical variables to the fprintf() to make sense of what is happening. -- jiw
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-08 14:58 +0100
Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-08 10:57 -0700
Re: How to implement diagnostic messages? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-08 20:53 +0100
Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-08 14:14 -0700
Re: How to implement diagnostic messages? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-09-09 09:30 +0200
Re: How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-11 18:27 +0100
Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-11 11:44 -0700
Re: How to implement diagnostic messages? Ian Collins <ian-news@hotmail.com> - 2011-09-09 10:33 +1200
Re: How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-11 18:33 +0100
Re: How to implement diagnostic messages? James Waldby <not@valid.invalid> - 2011-09-10 00:17 +0000
Re: How to implement diagnostic messages? Rui Maciel <rui.maciel@gmail.com> - 2011-09-11 18:41 +0100
Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-11 11:48 -0700
Re: How to implement diagnostic messages? Ian Collins <ian-news@hotmail.com> - 2011-09-12 08:47 +1200
Re: How to implement diagnostic messages? BGB <cr88192@hotmail.com> - 2011-09-11 14:56 -0700
Re: How to implement diagnostic messages? Ian Collins <ian-news@hotmail.com> - 2011-09-12 15:00 +1200
csiph-web