Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_log_add_func ( GPLogLevel  level,
GPLogFunc  func,
void *  data 

Add a function to get logging information.

level the maximum level of logging it will get, up to and including the passed value
func a GPLogFunc
data data
Adds a log function that will be called for each log message that is flagged with a log level that appears in given log level. This function returns an id that you can use for removing the log function again (using gp_log_remove_func).

an id or a gphoto2 error code

Definition at line 80 of file gphoto2-port-log.c.

References LogFunc::data, LogFunc::func, GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, LogFunc::id, and LogFunc::level.

      LogFunc *new_log_funcs;

      if (!func)
            return (GP_ERROR_BAD_PARAMETERS);

      if (!log_funcs)
            new_log_funcs = malloc (sizeof (LogFunc));
            new_log_funcs = realloc (log_funcs, sizeof (LogFunc) * 
                               (log_funcs_count + 1));
      if (!new_log_funcs)
            return (GP_ERROR_NO_MEMORY);

      log_funcs = new_log_funcs;

      log_funcs[log_funcs_count - 1].id = log_funcs_count;
      log_funcs[log_funcs_count - 1].level = level;
      log_funcs[log_funcs_count - 1].func = func;
      log_funcs[log_funcs_count - 1].data = data;

      return (log_funcs_count);

Generated by  Doxygen 1.6.0   Back to index