libgphoto2 photo camera library (libgphoto2) API  2.5.10.1
gphoto2-port-log.h File Reference
#include <stdarg.h>
Include dependency graph for gphoto2-port-log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GP_LOG_ALL   GP_LOG_DATA
 

Typedefs

typedef void(* GPLogFunc) (GPLogLevel level, const char *domain, const char *str, void *data)
 Logging function hook. More...
 

Enumerations

enum  GPLogLevel { GP_LOG_ERROR = 0, GP_LOG_VERBOSE = 1, GP_LOG_DEBUG = 2, GP_LOG_DATA = 3 }
 Logging level Specifies the logging severity level. More...
 

Functions

int gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data)
 Add a function to get logging information. More...
 
int gp_log_remove_func (int id)
 Remove a logging receiving function. More...
 
void gp_log (GPLogLevel level, const char *domain, const char *format,...)
 Log a debug or error message. More...
 
void gp_log_with_source_location (GPLogLevel level, const char *file, int line, const char *func, const char *format,...)
 
void gp_logv (GPLogLevel level, const char *domain, const char *format, va_list args)
 Log a debug or error message with va_list. More...
 
void gp_log_data (const char *domain, const char *data, unsigned int size, const char *format,...)
 Log data. More...
 

Detailed Description

Copyright 2001 Lutz Mueller lutz@.nosp@m.user.nosp@m.s.sf..nosp@m.net

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Macro Definition Documentation

#define GP_LOG_ALL   GP_LOG_DATA

GP_LOG_ALL:

Used by frontends if they want to be sure their callback function receives all messages. Defined as the highest debug level. Can make frontend code more understandable and extension of log levels easier.

Typedef Documentation

typedef void(* GPLogFunc) (GPLogLevel level, const char *domain, const char *str, void *data)

Logging function hook.

This is the function frontends can use to receive logging information from the libgphoto2 framework. It is set using gp_log_add_func() and removed using gp_log_remove_func() and will then receive the logging messages of the level specified.

Parameters
levelthe log level of the passed message, as set by the camera driver or libgphoto2
domainthe logging domain as set by the camera driver, or libgphoto2 function
strthe logmessage, without linefeed
datathe caller private data that was passed to gp_log_add_func()

Enumeration Type Documentation

enum GPLogLevel

Logging level Specifies the logging severity level.

Enumerator
GP_LOG_ERROR 

Log message is an error infomation.

GP_LOG_VERBOSE 

Log message is an verbose debug infomation.

GP_LOG_DEBUG 

Log message is an debug infomation.

GP_LOG_DATA 

Log message is a data hex dump.

Function Documentation

void gp_log ( GPLogLevel  level,
const char *  domain,
const char *  format,
  ... 
)

Log a debug or error message.

Parameters
levelgphoto2 log level
domainthe log domain
formata printf style format string
...the variable argumentlist for above format string

Logs a message at the given log level. You would normally use this function to log general debug output in a printf way.

References gp_log_add_func(), gp_log_data(), gp_log_remove_func(), and gp_logv().

Referenced by gp_context_progress_start(), gp_log_data(), gp_port_check_int(), gp_port_check_int_fast(), gp_port_read(), gp_port_usb_msg_class_read(), gp_port_usb_msg_interface_read(), gp_port_usb_msg_read(), and gp_port_write().

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

Add a function to get logging information.

Parameters
levelthe maximum level of logging it will get, up to and including the passed value
funca GPLogFunc
datadata

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).

Returns
an id or a gphoto2 error code

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

Referenced by gp_log().

void gp_log_data ( const char *  domain,
const char *  data,
unsigned int  size,
const char *  format,
  ... 
)

Log data.

domain the domain data the data to be logged size the size of the data

Takes the data and creates a formatted hexdump string. If you would like to log text messages, use gp_log instead.

References gp_log(), GP_LOG_DATA, HEXDUMP_COMPLETE_LINE, HEXDUMP_INIT_X, HEXDUMP_INIT_Y, and HEXDUMP_LINE_WIDTH.

Referenced by gp_log().

int gp_log_remove_func ( int  id)

Remove a logging receiving function.

Parameters
idan id (return value of gp_log_add_func)

Removes the log function with given id.

Returns
a gphoto2 error code

References GP_ERROR_BAD_PARAMETERS, and GP_OK.

Referenced by gp_log().

void gp_logv ( GPLogLevel  level,
const char *  domain,
const char *  format,
va_list  args 
)

Log a debug or error message with va_list.

Parameters
levelgphoto2 log level
domainthe domain
formatthe format
argsthe va_list corresponding to format

Logs a message at the given log level. You would normally use this function to log as yet unformatted strings.

References LogFunc::func.

Referenced by gp_log().