support --vips-info
now turns on glib g_info() output
This commit is contained in:
parent
2be0b97dce
commit
07e6ac1994
20
TODO
20
TODO
@ -1,23 +1,3 @@
|
||||
- need some simple way to turn on info output from CLI or env var
|
||||
|
||||
- switch to glib logging
|
||||
|
||||
vips_error() stuff must stay
|
||||
|
||||
vips_info() and vips_warn() can change
|
||||
|
||||
- switch to g_warning() and g_info(), have some compat stuff
|
||||
|
||||
just calls
|
||||
|
||||
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format, args);
|
||||
|
||||
also see
|
||||
|
||||
vips_info_set(), --vips-info, VIPS_INFO
|
||||
|
||||
|
||||
|
||||
- not sure about utf8 error messages on win
|
||||
|
||||
- strange:
|
||||
|
@ -734,6 +734,18 @@ void
|
||||
vips_info_set( gboolean info )
|
||||
{
|
||||
vips__info = info;
|
||||
|
||||
if( info ) {
|
||||
const char *old;
|
||||
char *new;
|
||||
|
||||
old = g_getenv( "G_MESSAGES_DEBUG" );
|
||||
if( !old )
|
||||
old = "";
|
||||
new = g_strdup_printf( "%s VIPS", old );
|
||||
g_setenv( "G_MESSAGES_DEBUG", new, TRUE );
|
||||
g_free( new );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -135,6 +135,14 @@ G_STMT_START { \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
/* The g_info() macro was added in 2.40.
|
||||
*/
|
||||
#ifndef g_info
|
||||
/* Hopefully we have varargs macros. Maybe revisit this.
|
||||
*/
|
||||
#define g_info(...) \
|
||||
g_log( G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__ )
|
||||
#endif
|
||||
|
||||
/* Various integer range clips. Record over/under flows.
|
||||
*/
|
||||
|
@ -82,6 +82,10 @@
|
||||
extern "C" {
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/* Use glib structured logging,
|
||||
*/
|
||||
#define G_LOG_USE_STRUCTURED
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <gmodule.h>
|
||||
|
@ -103,6 +103,27 @@
|
||||
*
|
||||
* The domain argument most of these functions take is not localised and is
|
||||
* supposed to indicate the component which failed.
|
||||
*
|
||||
* libvips uses g_warning() and g_info() to send warning and information
|
||||
* messages to the user. You can use the usual glib mechanisms to display or
|
||||
* divert these messages. For example, info messages are hidden by default, but
|
||||
* you can see them with:
|
||||
*
|
||||
* |[
|
||||
* $ G_MESSAGES_DEBUG=VIPS vipsthumbnail k2.jpg
|
||||
* VIPS-INFO: thumbnailing k2.jpg
|
||||
* VIPS-INFO: selected loader is VipsForeignLoadJpegFile
|
||||
* VIPS-INFO: input size is 1450 x 2048
|
||||
* VIPS-INFO: loading jpeg with factor 8 pre-shrink
|
||||
* VIPS-INFO: converting to processing space srgb
|
||||
* VIPS-INFO: residual reducev by 0.5
|
||||
* VIPS-INFO: 13 point mask
|
||||
* VIPS-INFO: using vector path
|
||||
* VIPS-INFO: residual reduceh by 0.5
|
||||
* VIPS-INFO: 13 point mask
|
||||
* VIPS-INFO: thumbnailing k2.jpg as ./tn_k2.jpg
|
||||
* ]|
|
||||
*
|
||||
*/
|
||||
|
||||
/* Make global array to keep the error message buffer.
|
||||
|
@ -343,6 +343,9 @@ vips_init( const char *argv0 )
|
||||
|
||||
/* Deprecated, this is just for compat.
|
||||
*/
|
||||
|
||||
/* If set by --vips-info.
|
||||
*/
|
||||
if( g_getenv( "VIPS_INFO" ) ||
|
||||
g_getenv( "IM_INFO" ) )
|
||||
vips_info_set( TRUE );
|
||||
@ -579,12 +582,12 @@ vips__ngettext( const char *msgid, const char *plural, unsigned long int n )
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vips_lib_version_cb( const gchar *option_name, const gchar *value,
|
||||
vips_lib_info_cb( const gchar *option_name, const gchar *value,
|
||||
gpointer data, GError **error )
|
||||
{
|
||||
printf( "libvips %s\n", VIPS_VERSION_STRING );
|
||||
vips_shutdown();
|
||||
exit( 0 );
|
||||
vips_info_set( TRUE );
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -605,9 +608,18 @@ vips_set_fatal_cb( const gchar *option_name, const gchar *value,
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vips_lib_version_cb( const gchar *option_name, const gchar *value,
|
||||
gpointer data, GError **error )
|
||||
{
|
||||
printf( "libvips %s\n", VIPS_VERSION_STRING );
|
||||
vips_shutdown();
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
static GOptionEntry option_entries[] = {
|
||||
{ "vips-info", 0, G_OPTION_FLAG_HIDDEN,
|
||||
G_OPTION_ARG_NONE, &vips__info,
|
||||
{ "vips-info", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
|
||||
G_OPTION_ARG_CALLBACK, (gpointer) &vips_lib_info_cb,
|
||||
N_( "show informative messages" ), NULL },
|
||||
{ "vips-fatal", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
|
||||
G_OPTION_ARG_CALLBACK, (gpointer) &vips_set_fatal_cb,
|
||||
|
Loading…
Reference in New Issue
Block a user