parallel safe version of fprintf for logging More...

#include "common.h"
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include "bu/log.h"
#include "bu/parallel.h"
Include dependency graph for log.c:

Go to the source code of this file.


void bu_log_indent_delta (int delta)
void bu_log_indent_vls (struct bu_vls *v)
void bu_log_add_hook (bu_hook_t func, void *clientdata)
void bu_log_delete_hook (bu_hook_t func, void *clientdata)
HIDDEN void log_call_hooks (void *buf)
void bu_log_hook_save_all (struct bu_hook_list *save_hlp)
void bu_log_hook_delete_all ()
void bu_log_hook_restore_all (struct bu_hook_list *restore_hlp)
HIDDEN void log_do_indent_level (struct bu_vls *new_vls, register const char *old_vls)
void bu_putchar (int c)
void bu_log (const char *fmt,...)
void bu_flog (FILE *fp, const char *fmt,...)

Detailed Description

parallel safe version of fprintf for logging

BRL-CAD support library, error logging routine. Note that the user may provide his own logging routine, by replacing these functions. That is why this is in file of its own. For example, LGT and RTSRV take advantage of this.

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.

int log_output_to_file(void *data, void *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, (void *)fp);
bu_log("Logging to file.\n");
bu_log_delete_hook(log_output_to_file, (void *)fp);
bu_log("Logging to stderr.\n");
return 0;

Definition in file log.c.

Function Documentation

HIDDEN void log_call_hooks ( void *  buf)

Definition at line 82 of file log.c.

References bu_hook_call().

Referenced by bu_flog(), bu_log(), and bu_putchar().

Here is the call graph for this function:

HIDDEN void log_do_indent_level ( struct bu_vls new_vls,
register const char *  old_vls 

This subroutine is used to append log_indent_level spaces into a printf() format specifier string, after each newline character is encountered.

It exists primarily for bu_shootray() to affect the indentation level of all messages at that recursion level, even if the calls to bu_log come from non-librt routines.

Definition at line 122 of file log.c.

References bu_vls_putc().

Referenced by bu_flog(), and bu_log().

Here is the call graph for this function: