- struct store_log_forward * next;
- const char * file;
- int line;
- const char * function;
- const char * string;
-};
-
-/* either forward the log to the listeners or store it for possible forwarding later */
-static void log_forward(const char *file, int line, const char *function, const char *string)
-{
- if (log_forward_count==0)
- {
- log_callback_t *cb, *next;
- cb = log_callbacks;
- /* DANGER!!!! the log callback can remove itself!!!! */
- while (cb)
- {
- next = cb->next;
- cb->fn(cb->priv, file, line, function, string);
- cb = next;
- }
- } else
- {
- struct store_log_forward *log = malloc(sizeof (struct store_log_forward));
- log->file = strdup(file);
- log->line = line;
- log->function = strdup(function);
- log->string = strdup(string);
- log->next = NULL;
- if (log_head==NULL)
- log_head = log;
- else
- {
- /* append to tail */
- struct store_log_forward * t;
- t = log_head;
- while (t->next!=NULL)
- {
- t = t->next;
- }
- t->next = log;
- }
- }
-}
-
-void log_try(void)
-{
- log_forward_count++;
-}
-
-void log_catch(void)
-{
- assert(log_forward_count>0);
- log_forward_count--;
-}
-
-void log_rethrow(void)
-{
- log_catch();
- if (log_forward_count==0)
- {
- struct store_log_forward *log;
-
- log = log_head;
- while (log != NULL)
- {
- log_forward(log->file, log->line, log->function, log->string);
-
- struct store_log_forward *t=log;
- log = log->next;
-
- free((void *)t->file);
- free((void *)t->function);
- free((void *)t->string);
- free(t);
-
- }
-
- log_head = NULL;
+ struct log_callback *cb, *next;
+ cb = log_callbacks;
+ /* DANGER!!!! the log callback can remove itself!!!! */
+ while (cb) {
+ next = cb->next;
+ cb->fn(cb->priv, file, line, function, string);
+ cb = next;