SphinxBase 5prealpha
err.c File Reference

Somewhat antiquated logging and error interface. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include "sphinxbase/err.h"
#include "sphinxbase/prim_type.h"
#include "sphinxbase/filename.h"
#include "sphinxbase/ckd_alloc.h"

Go to the source code of this file.

Functions

void err_msg (err_lvl_t lvl, const char *path, long ln, const char *fmt,...)
 
void err_msg_system (err_lvl_t lvl, const char *path, long ln, const char *fmt,...)
 
void err_logfp_cb (void *user_data, err_lvl_t lvl, const char *fmt,...)
 
int err_set_logfile (const char *path)
 Append all log messages to a given file. More...
 
void err_set_logfp (FILE *stream)
 Direct all logging to a given filehandle if default logfp callback is set. More...
 
FILE * err_get_logfp (void)
 Get the current logging filehandle. More...
 
void err_set_callback (err_cb_f cb, void *user_data)
 Sets function to output error messages. More...
 

Detailed Description

Somewhat antiquated logging and error interface.

Definition in file err.c.

Function Documentation

◆ err_get_logfp()

FILE * err_get_logfp ( void  )

Get the current logging filehandle.

Returns
Current logging filehandle, NULL if logging is disabled. Initially it returns stderr

Definition at line 267 of file err.c.

◆ err_logfp_cb()

void err_logfp_cb ( void *  user_data,
err_lvl_t  lvl,
const char *  fmt,
  ... 
)

Definition at line 224 of file err.c.

◆ err_msg()

void err_msg ( err_lvl_t  lvl,
const char *  path,
long  ln,
const char *  fmt,
  ... 
)

Definition at line 81 of file err.c.

◆ err_msg_system()

void err_msg_system ( err_lvl_t  lvl,
const char *  path,
long  ln,
const char *  fmt,
  ... 
)

Definition at line 158 of file err.c.

◆ err_set_callback()

void err_set_callback ( err_cb_f  callback,
void *  user_data 
)

Sets function to output error messages.

Use it to redirect the logging to your application. By default the handler which dumps messages to stderr is set.

Parameters
callbackcallback to pass messages too
user_datadata to pass to callback

Definition at line 278 of file err.c.

◆ err_set_logfile()

int err_set_logfile ( const char *  path)

Append all log messages to a given file.

Previous logging filehandle is closed (unless it was stdout or stderr).

Parameters
pathFile path to send log messages to
Returns
0 for success, <0 for failure (e.g. if file does not exist)

Definition at line 240 of file err.c.

◆ err_set_logfp()

void err_set_logfp ( FILE *  stream)

Direct all logging to a given filehandle if default logfp callback is set.

Parameters
streamFilehandle to send log messages to, or NULL to disable logging.

Definition at line 254 of file err.c.