[brlcad-commits] SF.net SVN: brlcad:[34303] brlcad/trunk/include/bu.h
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2009-04-23 11:40:39
|
Revision: 34303 http://brlcad.svn.sourceforge.net/brlcad/?rev=34303&view=rev Author: brlcad Date: 2009-04-23 11:40:32 +0000 (Thu, 23 Apr 2009) Log Message: ----------- include the logging example snippet in the header with a comment about stderr/stdout possibly changing. Modified Paths: -------------- brlcad/trunk/include/bu.h Modified: brlcad/trunk/include/bu.h =================================================================== --- brlcad/trunk/include/bu.h 2009-04-23 11:33:14 UTC (rev 34302) +++ brlcad/trunk/include/bu.h 2009-04-23 11:40:32 UTC (rev 34303) @@ -2142,7 +2142,35 @@ /** @} */ /** @addtogroup bu_log */ /** @{ */ -/* log.c */ +/** + * Here is an example of how to set up a custom logging callback. + * While bu_log presently writes to STDERR by default, this behavior + * should not be relied upon and may be changed to STDOUT in the + * future without notice. + * + * --- BEGIN EXAMPLE --- + * @code + int log_output_to_file(genptr_t data, genptr_t str) + { + FILE *fp = (FILE *)data; + fprintf(fp, "LOG: %s", str); + return 0; + } + + int main(int ac, char *av[]) + { + FILE *fp = fopen("whatever.log", "w+"); + bu_log_add_hook(log_output_to_file, (genptr_t)fp); + bu_log("Logging to file.\n"); + bu_log_delete_hook(log_output_to_file, (genptr_t)fp); + bu_log("Logging to stderr.\n"); + fclose(fp); + return 0; + } + * @endcode + * --- END EXAMPLE --- + * + */ BU_EXPORT BU_EXTERN(void bu_log_indent_delta, (int delta)); BU_EXPORT BU_EXTERN(void bu_log_indent_vls, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |