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...
 
int err_set_debug_level (int level)
 Set debugging verbosity level. More...
 
int err_get_debug_level (void)
 Get debugging verbosity level. 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

int err_get_debug_level ( void  )

Get debugging verbosity level.

Note that debugging messages are only enabled when compiled with -DDEBUG.

Definition at line 287 of file err.c.

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 268 of file err.c.

Referenced by cmd_ln_parse_r(), and err_set_logfile().

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
-callback to pass messages too.

Definition at line 293 of file err.c.

int err_set_debug_level ( int  level)

Set debugging verbosity level.

Note that debugging messages are only enabled when compiled with -DDEBUG.

Parameters
levelVerbosity level to set, or 0 to disable debug messages.

Definition at line 279 of file err.c.

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
fileFile path to send log messages to
Returns
0 for success, <0 for failure (e.g. if file does not exist)

Definition at line 241 of file err.c.

References err_get_logfp(), and err_set_logfp().

void err_set_logfp ( FILE *  stream)

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

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

Definition at line 255 of file err.c.

Referenced by err_set_logfile().