libgphoto2 photo camera library (libgphoto2) Internals
2.5.26
|
#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>
Go to the source code of this file.
Data Structures | |
struct | LogFunc |
Internal logging function entry. More... | |
Macros | |
#define | _DEFAULT_SOURCE |
#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. More... | |
char * | gpi_vsnprintf (const char *format, va_list args) |
int | gp_log_remove_func (int id) |
Remove a logging receiving function. More... | |
void | gp_log_data (const char *domain, const char *data, unsigned int size, const char *format,...) |
Log data. More... | |
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 (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,...) |
Variables | |
static LogFunc * | log_funcs = NULL |
static unsigned int | log_funcs_count = 0 |
Definition in file gphoto2-port-log.c.
#define _ | ( | String | ) | (String) |
Definition at line 46 of file gphoto2-port-log.c.
#define _DEFAULT_SOURCE |
Definition at line 24 of file gphoto2-port-log.c.
#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.
Definition at line 162 of file gphoto2-port-log.c.
#define HEXDUMP_COMPLETE_LINE |
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.
Definition at line 181 of file gphoto2-port-log.c.
#define HEXDUMP_INIT_X (HEXDUMP_OFFSET_WIDTH + HEXDUMP_BLOCK_DISTANCE) |
Initial value for x "pointer" (for hexdump)
Definition at line 165 of file gphoto2-port-log.c.
#define HEXDUMP_INIT_Y (HEXDUMP_INIT_X + 3 * 16 - 1 + HEXDUMP_BLOCK_DISTANCE) |
Initial value for y "pointer" (for ascii values)
Definition at line 168 of file gphoto2-port-log.c.
#define HEXDUMP_LINE_WIDTH (HEXDUMP_INIT_Y + 16) |
Used to switch to next line
Definition at line 171 of file gphoto2-port-log.c.
#define HEXDUMP_MIDDLE (HEXDUMP_INIT_X + 3 * 8 - 1) |
Used to put the '-' character in the middle of the hexdumps
Definition at line 174 of file gphoto2-port-log.c.
#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.
Definition at line 156 of file gphoto2-port-log.c.
#define N_ | ( | String | ) | (String) |
Definition at line 47 of file gphoto2-port-log.c.
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.
Definition at line 331 of file gphoto2-port-log.c.
References gp_logv(), and level.
Referenced by gp_bayer_expand(), gp_context_error(), 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.
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).
Definition at line 82 of file gphoto2-port-log.c.
References LogFunc::data, LogFunc::func, LogFunc::id, LogFunc::level, level, log_funcs, and log_funcs_count.
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.
Definition at line 205 of file gphoto2-port-log.c.
References gp_log(), GP_LOG_DATA, gpi_vsnprintf(), HEXDUMP_COMPLETE_LINE, HEXDUMP_INIT_X, HEXDUMP_INIT_Y, HEXDUMP_LINE_WIDTH, and result.
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.
Definition at line 138 of file gphoto2-port-log.c.
References GP_ERROR_BAD_PARAMETERS, GP_OK, log_funcs, and log_funcs_count.
void gp_log_with_source_location | ( | GPLogLevel | level, |
const char * | file, | ||
int | line, | ||
const char * | func, | ||
const char * | format, | ||
... | |||
) |
Definition at line 341 of file gphoto2-port-log.c.
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.
Definition at line 299 of file gphoto2-port-log.c.
References LogFunc::func, gpi_vsnprintf(), level, log_funcs, and log_funcs_count.
Referenced by gp_log(), and gp_log_with_source_location().
char* gpi_vsnprintf | ( | const char * | format, |
va_list | args | ||
) |
Definition at line 101 of file gphoto2-port-log.c.
Referenced by gp_context_error(), gp_context_message(), gp_context_progress_start(), gp_context_question(), gp_context_status(), gp_log_data(), and gp_logv().
|
static |
Definition at line 64 of file gphoto2-port-log.c.
Referenced by gp_log_add_func(), gp_log_remove_func(), and gp_logv().
|
static |
Definition at line 65 of file gphoto2-port-log.c.
Referenced by gp_log_add_func(), gp_log_remove_func(), and gp_logv().