#include "config.h"
#include <gphoto2/gphoto2-port-log.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <gphoto2/gphoto2-port-result.h>
Data Structures | |
struct | LogFunc |
Internal logging function entry. More... | |
Defines | |
#define | _(String) (String) |
#define | N_(String) (String) |
#define | HEXDUMP_OFFSET_WIDTH 4 |
#define | HEXDUMP_BLOCK_DISTANCE 2 |
#define | HEXDUMP_INIT_X (HEXDUMP_OFFSET_WIDTH + HEXDUMP_BLOCK_DISTANCE) |
#define | HEXDUMP_INIT_Y (HEXDUMP_INIT_X + 3 * 16 - 1 + HEXDUMP_BLOCK_DISTANCE) |
#define | HEXDUMP_LINE_WIDTH (HEXDUMP_INIT_Y + 16) |
#define | HEXDUMP_MIDDLE (HEXDUMP_INIT_X + 3 * 8 - 1) |
#define | HEXDUMP_COMPLETE_LINE |
Functions | |
int | gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data) |
Add a function to get logging information. | |
int | gp_log_remove_func (int id) |
Remove a logging receiving function. | |
void | gp_log_data (const char *domain, const char *data, unsigned int size) |
Log data. | |
void | gp_logv (GPLogLevel level, const char *domain, const char *format, va_list args) |
Log a debug or error message with va_list. | |
void | gp_log (GPLogLevel level, const char *domain, const char *format,...) |
Log a debug or error message. |
#define HEXDUMP_BLOCK_DISTANCE 2 |
Distance between offset, hexdump and ascii blocks. Note that HEXDUMP_COMPLETE_LINE needs to be changed when this value is changed.
#define HEXDUMP_COMPLETE_LINE |
{\ curline[HEXDUMP_OFFSET_WIDTH - 4] = hexchars[(index >> 12) & 0xf]; \ curline[HEXDUMP_OFFSET_WIDTH - 3] = hexchars[(index >> 8) & 0xf]; \ curline[HEXDUMP_OFFSET_WIDTH - 2] = hexchars[(index >> 4) & 0xf]; \ curline[HEXDUMP_OFFSET_WIDTH - 1] = '0'; \ curline[HEXDUMP_OFFSET_WIDTH + 0] = ' '; \ curline[HEXDUMP_OFFSET_WIDTH + 1] = ' '; \ curline[HEXDUMP_MIDDLE] = '-'; \ curline[HEXDUMP_INIT_Y-2] = ' '; \ curline[HEXDUMP_INIT_Y-1] = ' '; \ curline[HEXDUMP_LINE_WIDTH] = '\n'; \ curline = curline + (HEXDUMP_LINE_WIDTH + 1);}
We are lazy and do our typing only once. Please note that you have to add/remove some lines when increasing/decreasing the values of HEXDUMP_BLOCK_DISTANCE and/or HEXDUMP_OFFSET_WIDTH.
#define HEXDUMP_INIT_X (HEXDUMP_OFFSET_WIDTH + HEXDUMP_BLOCK_DISTANCE) |
Initial value for x "pointer" (for hexdump)
#define HEXDUMP_INIT_Y (HEXDUMP_INIT_X + 3 * 16 - 1 + HEXDUMP_BLOCK_DISTANCE) |
Initial value for y "pointer" (for ascii values)
Referenced by gp_log_data().
#define HEXDUMP_LINE_WIDTH (HEXDUMP_INIT_Y + 16) |
Used to switch to next line
Referenced by gp_log_data().
#define HEXDUMP_MIDDLE (HEXDUMP_INIT_X + 3 * 8 - 1) |
Used to put the '-' character in the middle of the hexdumps
#define HEXDUMP_OFFSET_WIDTH 4 |
Width of offset field in characters. Note that HEXDUMP_COMPLETE_LINE needs to be changed when this value is changed.
void gp_log | ( | GPLogLevel | level, | |
const char * | domain, | |||
const char * | format, | |||
... | ||||
) |
Log a debug or error message.
level | gphoto2 log level | |
domain | the log domain | |
format | a 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_logv().
Referenced by gp_abilities_list_lookup_model(), gp_camera_exit(), gp_camera_file_delete(), gp_camera_file_get(), gp_camera_file_get_info(), gp_camera_folder_delete_all(), gp_camera_folder_list_files(), gp_camera_folder_list_folders(), gp_camera_folder_put_file(), gp_camera_free(), gp_camera_init(), gp_camera_set_abilities(), gp_camera_set_port_speed(), gp_camera_unref(), gp_file_adjust_name_for_mime_type(), gp_file_append(), gp_file_copy(), gp_file_get_data_and_size(), gp_file_open(), gp_file_save(), gp_file_set_data_and_size(), gp_file_slurp(), gp_filesystem_append(), gp_filesystem_delete_all(), gp_filesystem_list_files(), gp_filesystem_list_folders(), gp_filesystem_remove_dir(), gp_filesystem_reset(), gp_list_append(), gp_list_set_name(), gp_list_set_value(), gp_log_data(), gp_port_check_int(), gp_port_check_int_fast(), gp_port_close(), gp_port_flush(), gp_port_free(), gp_port_get_pin(), gp_port_get_timeout(), gp_port_info_list_count(), gp_port_info_list_get_info(), gp_port_info_list_load(), gp_port_info_list_lookup_name(), gp_port_info_list_lookup_path(), gp_port_new(), gp_port_open(), gp_port_read(), gp_port_seek(), gp_port_send_break(), gp_port_send_scsi_cmd(), gp_port_set_error(), gp_port_set_info(), gp_port_set_pin(), gp_port_set_settings(), gp_port_set_timeout(), gp_port_usb_clear_halt(), gp_port_usb_msg_class_read(), gp_port_usb_msg_class_write(), gp_port_usb_msg_interface_read(), gp_port_usb_msg_interface_write(), gp_port_usb_msg_read(), gp_port_usb_msg_write(), gp_port_write(), gp_setting_set(), and gp_widget_set_value().
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).
References LogFunc::data, LogFunc::func, GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, LogFunc::id, and LogFunc::level.
void gp_log_data | ( | const char * | domain, | |
const char * | data, | |||
unsigned int | size | |||
) |
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, GP_LOG_ERROR, HEXDUMP_INIT_Y, and HEXDUMP_LINE_WIDTH.
Referenced by gp_port_check_int(), gp_port_check_int_fast(), gp_port_read(), gp_port_send_scsi_cmd(), gp_port_usb_msg_class_read(), gp_port_usb_msg_class_write(), gp_port_usb_msg_interface_read(), gp_port_usb_msg_interface_write(), gp_port_usb_msg_read(), gp_port_usb_msg_write(), and gp_port_write().
int gp_log_remove_func | ( | int | id | ) |
Remove a logging receiving function.
id | an id (return value of gp_log_add_func) |
Removes the log function with given id.
References GP_ERROR_BAD_PARAMETERS, and GP_OK.
void gp_logv | ( | GPLogLevel | level, | |
const char * | domain, | |||
const char * | format, | |||
va_list | args | |||
) |
Log a debug or error message with va_list.
level | gphoto2 log level | |
domain | the domain | |
format | the format | |
args | the 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_context_message(), and gp_log().