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.
void | err_set_logfp (FILE *stream)
| Direct all logging to a given filehandle if default logfp callback is set.
FILE * | err_get_logfp (void)
| Get the current logging filehandle.
int | err_set_debug_level (int level)
| Set debugging verbosity level.
int | err_get_debug_level (void)
| Get debugging verbosity level.
void | err_set_callback (err_cb_f cb, void *user_data)
| Sets function to output error messages.

## Detailed Description

Somewhat antiquated logging and error interface.

Definition in file err.c.

## Function Documentation

## err_get_debug_level()

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.

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

Referenced by cmd_ln_parse_r(), and err_set_logfile().

## err_logfp_cb()

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

Definition at line 226 of file err.c.

## err_msg()

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

Definition at line 83 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 160 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

  callback | callback to pass messages too
  user_data | data to pass to callback

Definition at line 293 of file err.c.

## err_set_debug_level()

int err_set_debug_level | ( | int | level | ) |

Set debugging verbosity level.

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

Parameters

  level | Verbosity level to set, or 0 to disable debug messages.

Definition at line 279 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

  path | File 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().

## err_set_logfp()

void err_set_logfp | ( | FILE * | stream | ) |

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

Parameters

  stream | Filehandle to send log messages to, or NULL to disable logging.

Definition at line 255 of file err.c.

Referenced by err_set_logfile().