Consolidate logging

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2017-04-15 11:58:49 +02:00
parent ba9e1fb92a
commit cfbe4027bc
No known key found for this signature in database
GPG Key ID: AC203F96E2C34BB7
16 changed files with 121 additions and 123 deletions

View File

@ -24,6 +24,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#define G_LOG_DOMAIN "Dialogs.Combi"
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
@ -85,7 +88,7 @@ static void combi_mode_parse_switchers ( Mode *sw )
}
else {
// Report error, don't continue.
fprintf ( stderr, "Invalid script switcher: %s\n", token );
g_warning ( "Invalid script switcher: %s", token );
token = NULL;
}
}
@ -240,7 +243,7 @@ static char * combi_get_completion ( const Mode *sw, unsigned int index )
}
}
// Should never get here.
g_error ( "Failure, could not resolve sub-switcher." );
g_assert_not_reached ();
return NULL;
}

View File

@ -25,6 +25,8 @@
*
*/
#define G_LOG_DOMAIN "Dialogs.DMenu"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -47,9 +49,6 @@
#include "xrmoptions.h"
#include "view.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Dialogs.DMenu"
struct range_pair
{
unsigned int start;
@ -444,7 +443,7 @@ static int dmenu_mode_init ( Mode *sw )
char *estr = rofi_expand_path ( str );
fd = open ( str, O_RDONLY );
if ( fd < 0 ) {
char *msg = g_markup_printf_escaped ( "Failed to open file: <b>%s</b>:\n\t<i>%s</i>", estr, strerror ( errno ) );
char *msg = g_markup_printf_escaped ( "Failed to open file: <b>%s</b>:\n\t<i>%s</i>", estr, g_strerror ( errno ) );
rofi_view_error_dialog ( msg, TRUE );
g_free ( msg );
g_free ( estr );

View File

@ -24,6 +24,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#define G_LOG_DOMAIN "Dialogs.DRun"
#include <config.h>
#ifdef ENABLE_DRUN
#include <stdlib.h>
@ -48,8 +51,6 @@
#include "dialogs/drun.h"
#define DRUN_CACHE_FILE "rofi2.druncache"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Dialogs.DRun"
#define GET_CAT_PARSE_TIME
@ -147,24 +148,24 @@ static void exec_cmd_entry ( DRunModeEntry *e )
GError *error = NULL;
GRegex *reg = g_regex_new ( "%[a-zA-Z]", 0, 0, &error );
if ( error != NULL ) {
fprintf ( stderr, "Internal error, failed to create regex: %s.\n", error->message );
g_warning ( "Internal error, failed to create regex: %s.", error->message );
g_error_free ( error );
return;
}
struct RegexEvalArg earg = { .e = e, .success = TRUE };
char *str = g_regex_replace_eval ( reg, e->exec, -1, 0, 0, drun_helper_eval_cb, &earg, &error );
if ( error != NULL ) {
fprintf ( stderr, "Internal error, failed replace field codes: %s.\n", error->message );
g_warning ( "Internal error, failed replace field codes: %s.", error->message );
g_error_free ( error );
return;
}
g_regex_unref ( reg );
if ( earg.success == FALSE ) {
fprintf ( stderr, "Invalid field code in Exec line: %s.\n", e->exec );;
g_warning ( "Invalid field code in Exec line: %s.", e->exec );;
return;
}
if ( str == NULL ) {
fprintf ( stderr, "Nothing to execute after processing: %s.\n", e->exec );;
g_warning ( "Nothing to execute after processing: %s.", e->exec );;
return;
}
gchar *fp = rofi_expand_path ( g_strstrip ( str ) );
@ -237,7 +238,7 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
// Name key is required.
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Name", NULL ) ) {
g_debug ( "Invalid DesktopFile: '%s', no 'Name' key present.\n", path );
g_debug ( "Invalid DesktopFile: '%s', no 'Name' key present.", path );
g_key_file_free ( kf );
return FALSE;
}
@ -258,7 +259,7 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
}
// We need Exec, don't support DBusActivatable
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
g_debug ( "Unsupported DesktopFile: '%s', no 'Exec' key present.\n", path );
g_debug ( "Unsupported DesktopFile: '%s', no 'Exec' key present.", path );
g_key_file_free ( kf );
return FALSE;
}

View File

@ -29,6 +29,10 @@
* \ingroup RUNMode
* @{
*/
/** The log domain of this dialog. */
#define G_LOG_DOMAIN "Dialogs.Run"
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
@ -56,10 +60,6 @@
*/
#define RUN_CACHE_FILE "rofi-3.runcache"
/** The log domain of this dialog. */
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Dialogs.Run"
/**
* The internal data structure holding the private data of the Run Mode.
*/
@ -86,7 +86,7 @@ static void exec_cmd ( const char *cmd, int run_in_term )
gsize lf_cmd_size = 0;
gchar *lf_cmd = g_locale_from_utf8 ( cmd, -1, NULL, &lf_cmd_size, &error );
if ( error != NULL ) {
fprintf ( stderr, "Failed to convert command to locale encoding: %s\n", error->message );
g_warning ( "Failed to convert command to locale encoding: %s", error->message );
g_error_free ( error );
return;
}
@ -188,8 +188,8 @@ static char ** get_apps_external ( char **retv, unsigned int *length, unsigned i
free ( buffer );
}
if ( fclose ( inp ) != 0 ) {
fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n",
strerror ( errno ) );
g_warning ( "Failed to close stdout off executor script: '%s'",
g_strerror ( errno ) );
}
}
}

View File

@ -25,6 +25,8 @@
*
*/
#define G_LOG_DOMAIN "Dialogs.Script"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -66,8 +68,8 @@ static char **get_script_output ( const char *command, unsigned int *length )
free ( buffer );
}
if ( fclose ( inp ) != 0 ) {
fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n",
strerror ( errno ) );
g_warning ( "Failed to close stdout off executor script: '%s'",
g_strerror ( errno ) );
}
}
}
@ -201,7 +203,7 @@ Mode *script_switcher_parse_setup ( const char *str )
return sw;
}
fprintf ( stderr, "The script command '%s' has %u options, but needs 2: <name>:<script>.\n", str, index );
g_warning ( "The script command '%s' has %u options, but needs 2: <name>:<script>.", str, index );
script_switcher_free ( sw );
return NULL;
}

View File

@ -29,6 +29,12 @@
* \ingroup SSHMode
* @{
*/
/**
* Log domain for the ssh modi.
*/
#define G_LOG_DOMAIN "Dialogs.Ssh"
#include <config.h>
#include <glib.h>
#include <stdlib.h>
@ -50,13 +56,6 @@
#include "history.h"
#include "dialogs/ssh.h"
/**
* Log domain for the ssh modi.
*/
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Dialogs.Ssh"
/**
* Name of the history file where previously choosen hosts are stored.
*/
@ -181,7 +180,7 @@ static char **read_known_hosts_file ( char ** retv, unsigned int *length )
free ( buffer );
}
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close hosts file: '%s'\n", strerror ( errno ) );
g_warning ( "Failed to close hosts file: '%s'", g_strerror ( errno ) );
}
}
@ -256,7 +255,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
free ( buffer );
}
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close hosts file: '%s'\n", strerror ( errno ) );
g_warning ( "Failed to close hosts file: '%s'", g_strerror ( errno ) );
}
}
@ -357,7 +356,7 @@ static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned
}
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close ssh configuration file: '%s'\n", strerror ( errno ) );
g_warning ( "Failed to close ssh configuration file: '%s'", g_strerror ( errno ) );
}
}
}

View File

@ -24,6 +24,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#define G_LOG_DOMAIN "Dialogs.Window"
#include <config.h>
#ifdef WINDOW_MODE
@ -56,9 +59,6 @@
#define CLIENTSTATE 10
#define CLIENTWINDOWTYPE 10
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Dialogs.Window"
// a manageable window
typedef struct
{

View File

@ -25,6 +25,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#define G_LOG_DOMAIN "Helper"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -51,9 +54,6 @@
#include "rofi.h"
#include "view.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Helper"
/**
* Textual description of positioning rofi.
*/
@ -383,7 +383,7 @@ char helper_parse_char ( const char *arg )
if ( len > 2 && arg[0] == '\\' && arg[1] == 'x' ) {
return (char) strtol ( &arg[2], NULL, 16 );
}
fprintf ( stderr, "Failed to parse character string: \"%s\"\n", arg );
g_warning ( "Failed to parse character string: \"%s\"", arg );
// for now default to newline.
return '\n';
}
@ -491,22 +491,22 @@ int create_pid_file ( const char *pidfile )
int fd = g_open ( pidfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR );
if ( fd < 0 ) {
fprintf ( stderr, "Failed to create pid file: '%s'.\n", pidfile );
g_warning ( "Failed to create pid file: '%s'.", pidfile );
return -1;
}
// Set it to close the File Descriptor on exit.
int flags = fcntl ( fd, F_GETFD, NULL );
flags = flags | FD_CLOEXEC;
if ( fcntl ( fd, F_SETFD, flags, NULL ) < 0 ) {
fprintf ( stderr, "Failed to set CLOEXEC on pidfile.\n" );
g_warning ( "Failed to set CLOEXEC on pidfile." );
remove_pid_file ( fd );
return -1;
}
// Try to get exclusive write lock on FD
int retv = flock ( fd, LOCK_EX | LOCK_NB );
if ( retv != 0 ) {
fprintf ( stderr, "Failed to set lock on pidfile: Rofi already running?\n" );
fprintf ( stderr, "Got error: %d %s\n", retv, strerror ( errno ) );
g_warning ( "Failed to set lock on pidfile: Rofi already running?" );
g_warning ( "Got error: %d %s", retv, g_strerror ( errno ) );
remove_pid_file ( fd );
return -1;
}
@ -526,7 +526,7 @@ void remove_pid_file ( int fd )
{
if ( fd >= 0 ) {
if ( close ( fd ) ) {
fprintf ( stderr, "Failed to close pidfile: '%s'\n", strerror ( errno ) );
g_warning ( "Failed to close pidfile: '%s'", g_strerror ( errno ) );
}
}
}

View File

@ -145,7 +145,7 @@ void history_set ( const char *filename, const char *entry )
list = __history_get_element_list ( fd, &length );
// Close file, if fails let user know on stderr.
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
g_warning ( "Failed to close history file: %s", g_strerror ( errno ) );
}
}
// Look if the entry exists.
@ -178,14 +178,14 @@ void history_set ( const char *filename, const char *entry )
fd = fopen ( filename, "w" );
if ( fd == NULL ) {
fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) );
g_warning ( "Failed to open file: %s", g_strerror ( errno ) );
}
else {
// Write list.
__history_write_element_list ( fd, list, length );
// Close file, if fails let user know on stderr.
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
g_warning ( "Failed to close history file: %s", g_strerror ( errno ) );
}
}
// Free the list.
@ -208,7 +208,7 @@ void history_remove ( const char *filename, const char *entry )
// Open file for reading and writing.
FILE *fd = g_fopen ( filename, "r" );
if ( fd == NULL ) {
fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) );
g_warning ( "Failed to open file: %s", g_strerror ( errno ) );
return;
}
// Get list.
@ -216,7 +216,7 @@ void history_remove ( const char *filename, const char *entry )
// Close file, if fails let user know on stderr.
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
g_warning ( "Failed to close history file: %s", g_strerror ( errno ) );
}
// Find entry.
for ( unsigned int iter = 0; !found && iter < length; iter++ ) {
@ -244,11 +244,11 @@ void history_remove ( const char *filename, const char *entry )
__history_write_element_list ( fd, list, length );
// Close file, if fails let user know on stderr.
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
g_warning ( "Failed to close history file: %s", g_strerror ( errno ) );
}
}
else{
fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) );
g_warning ( "Failed to open file: %s", g_strerror ( errno ) );
}
}
@ -277,7 +277,7 @@ char ** history_get_list ( const char *filename, unsigned int *length )
// File that does not exists is not an error, so ignore it.
// Everything else? panic.
if ( errno != ENOENT ) {
fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) );
g_warning ( "Failed to open file: %s", g_strerror ( errno ) );
}
return NULL;
}
@ -298,7 +298,7 @@ char ** history_get_list ( const char *filename, unsigned int *length )
// Close file, if fails let user know on stderr.
if ( fclose ( fd ) != 0 ) {
fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) );
g_warning ( "Failed to close history file: %s", g_strerror ( errno ) );
}
return retv;
}

View File

@ -25,6 +25,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define G_LOG_DOMAIN "Rofi"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -75,9 +77,6 @@
// TODO: move this check to mode.c
#include "mode-private.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Rofi"
// Pidfile.
char *pidfile = NULL;
const char *cache_dir = NULL;
@ -310,7 +309,7 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
break;
}
}
fprintf ( stderr, " * %s%s%s%s\n",
printf ( " * %s%s%s%s\n",
active?"+":"" ,
is_term ? (active?color_green:color_red) : "",
available_modi[i]->name,
@ -367,9 +366,9 @@ static void help_print_disabled_mode ( const char *mode )
int is_term = isatty ( fileno ( stdout ) );
// Only output to terminal
if ( is_term ) {
fprintf ( stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n",
g_warning ( "Mode %s%s%s is not enabled. I have enabled it for now.",
color_red, mode, color_reset );
fprintf ( stderr, "Please consider adding %s%s%s to the list of enabled modi: %smodi: %s%s%s,%s%s.\n",
g_warning ( "Please consider adding %s%s%s to the list of enabled modi: %smodi: %s%s%s,%s%s.",
color_red, mode, color_reset,
color_green, config.modi, color_reset,
color_red, mode, color_reset
@ -533,7 +532,7 @@ static void rofi_collect_modi_dir ( const char *base_dir )
Mode *m = NULL;
if ( g_module_symbol ( mod, "mode", (gpointer *) &m ) ) {
if ( m->abi_version != ABI_VERSION ) {
fprintf ( stderr, "ABI version of plugin does not match: %08X expecting: %08X\n", m->abi_version, ABI_VERSION );
g_warning ( "ABI version of plugin does not match: %08X expecting: %08X", m->abi_version, ABI_VERSION );
g_module_close ( mod );
}
else {
@ -544,7 +543,7 @@ static void rofi_collect_modi_dir ( const char *base_dir )
}
}
else {
fprintf ( stderr, "Symbol 'mode' not found in module: %s\n", fn );
g_warning ( "Symbol 'mode' not found in module: %s", fn );
g_module_close ( mod );
}
}
@ -622,7 +621,7 @@ static int add_mode ( const char * token )
}
else {
// Report error, don't continue.
fprintf ( stderr, "Invalid script mode: %s\n", token );
g_warning ( "Invalid script mode: %s", token );
}
}
return ( index == num_modi ) ? -1 : (int) index;
@ -664,7 +663,7 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
if ( ev == NULL ) {
int status = xcb_connection_has_error ( xcb->connection );
if(status > 0) {
fprintf ( stderr, "The XCB connection to X server had a fatal error: %d\n", status );
g_warning ( "The XCB connection to X server had a fatal error: %d", status );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE;
} else {
@ -732,7 +731,7 @@ static void error_trap_push ( G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xc
static void error_trap_pop ( G_GNUC_UNUSED SnDisplay *display, xcb_connection_t *xdisplay )
{
if ( error_trap_depth == 0 ) {
fprintf ( stderr, "Error trap underflow!\n" );
g_warning ( "Error trap underflow!" );
exit ( EXIT_FAILURE );
}
@ -747,7 +746,7 @@ static gboolean lazy_grab_pointer ( G_GNUC_UNUSED gpointer data )
{
// After 5 sec.
if ( lazy_grab_retry_count_pt > ( 5 * 1000 ) ) {
fprintf ( stderr, "Failed to grab pointer after %u times. Giving up.\n", lazy_grab_retry_count_pt );
g_warning ( "Failed to grab pointer after %u times. Giving up.", lazy_grab_retry_count_pt );
return G_SOURCE_REMOVE;
}
if ( take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) {
@ -760,7 +759,7 @@ static gboolean lazy_grab_keyboard ( G_GNUC_UNUSED gpointer data )
{
// After 5 sec.
if ( lazy_grab_retry_count_kb > ( 5 * 1000 ) ) {
fprintf ( stderr, "Failed to grab keyboard after %u times. Giving up.\n", lazy_grab_retry_count_kb );
g_warning ( "Failed to grab keyboard after %u times. Giving up.", lazy_grab_retry_count_kb );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE;
}
@ -792,12 +791,12 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
if ( ( window_flags & MENU_NORMAL_WINDOW ) == 0 ) {
if ( find_arg ( "-no-lazy-grab" ) >= 0 ) {
if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb ), 500 ) ) {
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
g_warning ( "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE;
}
if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 100 ) ) {
fprintf ( stderr, "Failed to grab mouse pointer, even after %d uS.", 100 * 1000 );
g_warning ( "Failed to grab mouse pointer, even after %d uS.", 100 * 1000 );
}
}
else {
@ -874,7 +873,7 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
run_switcher ( index );
}
else {
fprintf ( stderr, "The %s mode has not been enabled\n", sname );
g_warning ( "The %s mode has not been enabled", sname );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE;
}
@ -908,9 +907,9 @@ int main ( int argc, char *argv[] )
// Version
if ( find_arg ( "-v" ) >= 0 || find_arg ( "-version" ) >= 0 ) {
#ifdef GIT_VERSION
fprintf ( stdout, "Version: "GIT_VERSION "\n" );
g_print ( "Version: "GIT_VERSION "\n" );
#else
fprintf ( stdout, "Version: "VERSION "\n" );
g_print ( "Version: "VERSION "\n" );
#endif
return EXIT_SUCCESS;
}
@ -935,7 +934,7 @@ int main ( int argc, char *argv[] )
cache_dir = g_get_user_cache_dir ();
if ( g_mkdir_with_parents ( cache_dir, 0700 ) < 0 ) {
fprintf ( stderr, "Failed to create cache directory: %s\n", strerror ( errno ) );
g_warning ( "Failed to create cache directory: %s", g_strerror ( errno ) );
return EXIT_FAILURE;
}
@ -943,7 +942,7 @@ int main ( int argc, char *argv[] )
const char *path = g_get_user_runtime_dir ();
if ( path ) {
if ( g_mkdir_with_parents ( path, 0700 ) < 0 ) {
g_warning ( "Failed to create user runtime directory: %s with error: %s\n", path, strerror ( errno ) );
g_warning ( "Failed to create user runtime directory: %s with error: %s", path, g_strerror ( errno ) );
pidfile = g_build_filename ( g_get_home_dir (), ".rofi.pid", NULL );
}
else {
@ -966,7 +965,7 @@ int main ( int argc, char *argv[] )
TICK ();
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
g_warning ( "Failed to set locale." );
cleanup ();
return EXIT_FAILURE;
}
@ -978,7 +977,7 @@ int main ( int argc, char *argv[] )
xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Failed to open display: %s", display_str );
g_warning( "Failed to open display: %s", display_str );
cleanup ();
return EXIT_FAILURE;
}
@ -996,7 +995,7 @@ int main ( int argc, char *argv[] )
xcb_generic_error_t *errors = NULL;
xcb_ewmh_init_atoms_replies ( &xcb->ewmh, ac, &errors );
if ( errors ) {
fprintf ( stderr, "Failed to create EWMH atoms\n" );
g_warning ( "Failed to create EWMH atoms" );
free ( errors );
}
// Discover the current active window manager.
@ -1005,14 +1004,14 @@ int main ( int argc, char *argv[] )
if ( xkb_x11_setup_xkb_extension ( xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
fprintf ( stderr, "cannot setup XKB extension!\n" );
g_warning ( "cannot setup XKB extension!" );
cleanup ();
return EXIT_FAILURE;
}
xkb.context = xkb_context_new ( XKB_CONTEXT_NO_FLAGS );
if ( xkb.context == NULL ) {
fprintf ( stderr, "cannot create XKB context!\n" );
g_warning ( "cannot create XKB context!" );
cleanup ();
return EXIT_FAILURE;
}
@ -1063,13 +1062,13 @@ int main ( int argc, char *argv[] )
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS );
if ( xkb.keymap == NULL ) {
fprintf ( stderr, "Failed to get Keymap for current keyboard device.\n" );
g_warning ( "Failed to get Keymap for current keyboard device." );
cleanup ();
return EXIT_FAILURE;
}
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
if ( xkb.state == NULL ) {
fprintf ( stderr, "Failed to get state object for current keyboard device.\n" );
g_warning ( "Failed to get state object for current keyboard device." );
cleanup ();
return EXIT_FAILURE;
}
@ -1079,18 +1078,18 @@ int main ( int argc, char *argv[] )
xkb.compose.state = xkb_compose_state_new ( xkb.compose.table, 0 );
}
else {
fprintf ( stderr, "Failed to get keyboard compose table. Trying to limp on.\n" );
g_warning ( "Failed to get keyboard compose table. Trying to limp on." );
}
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
g_warning ( "Connection has error" );
cleanup ();
return EXIT_FAILURE;
}
x11_setup ( &xkb );
TICK_N ( "Setup xkb" );
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
g_warning ( "Connection has error" );
cleanup ();
return EXIT_FAILURE;
}
@ -1100,7 +1099,7 @@ int main ( int argc, char *argv[] )
// startup not.
xcb->sndisplay = sn_xcb_display_new ( xcb->connection, error_trap_push, error_trap_pop );
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
g_warning ( "Connection has error" );
cleanup ();
return EXIT_FAILURE;
}
@ -1109,7 +1108,7 @@ int main ( int argc, char *argv[] )
xcb->sncontext = sn_launchee_context_new_from_environment ( xcb->sndisplay, xcb->screen_nbr );
}
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
g_warning ( "Connection has error" );
cleanup ();
return EXIT_FAILURE;
}
@ -1162,11 +1161,11 @@ int main ( int argc, char *argv[] )
}
if ( rofi_theme_is_empty ( ) ) {
if ( rofi_theme_parse_string ( default_theme ) ) {
fprintf ( stderr, "Failed to parse default theme. Giving up..\n" );
g_warning ( "Failed to parse default theme. Giving up.." );
if ( list_of_error_msgs ) {
for ( GList *iter = g_list_first ( list_of_error_msgs );
iter != NULL; iter = g_list_next ( iter ) ) {
fprintf ( stderr, "Error: %s%s%s\n",
g_warning ( "Error: %s%s%s",
color_bold, ( (GString *) iter->data )->str, color_reset );
}
}

View File

@ -1,3 +1,6 @@
#define G_LOG_DOMAIN "Theme"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@ -10,10 +13,6 @@
#include "view.h"
#include "rofi.h"
/** Logging domain for theme */
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Theme"
/**
* Name of the property type
*/

View File

@ -24,6 +24,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/** The Rofi View log domain */
#define G_LOG_DOMAIN "View"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -63,10 +66,6 @@
#include "theme.h"
/** The Rofi View log domain */
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "View"
#include "xcb.h"
/**
* @param state The handle to the view
@ -178,12 +177,12 @@ static void menu_capture_screenshot ( void )
const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
if ( CacheState.edit_surf == NULL ) {
// Nothing to store.
fprintf ( stderr, "There is no rofi surface to store\n" );
g_warning ( "There is no rofi surface to store" );
return;
}
const char *xdg_pict_dir = g_get_user_special_dir ( G_USER_DIRECTORY_PICTURES );
if ( outp == NULL && xdg_pict_dir == NULL ) {
fprintf ( stderr, "XDG user picture directory or ROFI_PNG_OUTPUT is not set. Cannot store screenshot.\n" );
g_warning ( "XDG user picture directory or ROFI_PNG_OUTPUT is not set. Cannot store screenshot." );
return;
}
// Get current time.
@ -210,10 +209,10 @@ static void menu_capture_screenshot ( void )
else {
fpath = g_strdup ( outp );
}
fprintf ( stderr, color_green "Storing screenshot %s\n"color_reset, fpath );
g_warning ( color_green "Storing screenshot %s\n"color_reset, fpath );
cairo_status_t status = cairo_surface_write_to_png ( CacheState.edit_surf, fpath );
if ( status != CAIRO_STATUS_SUCCESS ) {
fprintf ( stderr, "Failed to produce screenshot '%s', got error: '%s'\n", fpath,
g_warning ( "Failed to produce screenshot '%s', got error: '%s'", fpath,
cairo_status_to_string ( status ) );
}
g_free ( fpath );
@ -978,7 +977,7 @@ void rofi_view_update ( RofiViewState *state, gboolean qr )
static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t *xse )
{
if ( xse->property == XCB_ATOM_NONE ) {
fprintf ( stderr, "Failed to convert selection\n" );
g_warning ( "Failed to convert selection" );
}
else if ( xse->property == xcb->ewmh.UTF8_STRING ) {
gchar *text = window_get_text_prop ( CacheState.main_window, xcb->ewmh.UTF8_STRING );
@ -999,7 +998,7 @@ static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t
g_free ( text );
}
else {
fprintf ( stderr, "Failed\n" );
g_warning ( "Failed" );
}
}
@ -1443,7 +1442,7 @@ void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *ev, xkb_st
CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height );
CacheState.edit_draw = cairo_create ( CacheState.edit_surf );
g_debug ( "Re-size window based external request: %d %d\n", state->width, state->height );
g_debug ( "Re-size window based external request: %d %d", state->width, state->height );
widget_resize ( WIDGET ( state->main_window ), state->width, state->height );
}
}
@ -1791,7 +1790,7 @@ void rofi_view_workers_initialize ( void )
}
// If error occured during setup of pool, tell user and exit.
if ( error != NULL ) {
fprintf ( stderr, "Failed to setup thread pool: '%s'", error->message );
g_warning ( "Failed to setup thread pool: '%s'", error->message );
g_error_free ( error );
exit ( EXIT_FAILURE );
}

View File

@ -24,6 +24,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define G_LOG_DOMAIN "Widgets.Box"
#include <config.h>
#include <stdio.h>
#include "widgets/widget.h"
@ -31,9 +33,6 @@
#include "widgets/box.h"
#include "theme.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Widgets.Box"
/** Default spacing used in the box*/
#define DEFAULT_SPACING 2

View File

@ -24,6 +24,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define G_LOG_DOMAIN "Widgets.Window"
#include <config.h>
#include <stdio.h>
#include "widgets/widget.h"
@ -31,9 +33,6 @@
#include "widgets/container.h"
#include "theme.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Widgets.Window"
struct _window
{
widget widget;

View File

@ -25,6 +25,10 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/** Log domain for this module */
#define G_LOG_DOMAIN "X11Helper"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -52,11 +56,6 @@
#define INTERSECT( x, y, x1, y1, w1, h1 ) ( ( ( ( x ) >= ( x1 ) ) && ( ( x ) < ( x1 + w1 ) ) ) && ( ( ( y ) >= ( y1 ) ) && ( ( y ) < ( y1 + h1 ) ) ) )
#include "x11-helper.h"
#include "xkb-internal.h"
/** Log domain for this module */
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "X11Helper"
WindowManager current_window_manager = WM_EWHM;
/**
@ -523,7 +522,7 @@ int monitor_active ( workarea *mon )
if ( monitor_get_dimension ( mon_id, mon ) ) {
return TRUE;
}
fprintf ( stderr, "Failed to find selected monitor.\n" );
g_warning ( "Failed to find selected monitor." );
}
else {
return monitor_active_from_id ( mon_id, mon );
@ -538,7 +537,7 @@ int take_pointer ( xcb_window_t w, int iters )
int i = 0;
while ( TRUE ) {
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
g_warning ( "Connection has error" );
exit ( EXIT_FAILURE );
}
xcb_grab_pointer_cookie_t cc = xcb_grab_pointer ( xcb->connection, 1, w, XCB_EVENT_MASK_BUTTON_RELEASE,
@ -563,7 +562,7 @@ int take_keyboard ( xcb_window_t w, int iters )
int i = 0;
while ( TRUE ) {
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
g_warning ( "Connection has error" );
exit ( EXIT_FAILURE );
}
xcb_grab_keyboard_cookie_t cc = xcb_grab_keyboard ( xcb->connection,

View File

@ -368,7 +368,7 @@ static void __config_parser_set_property ( XrmOption *option, const Property *p
{
if ( option->type == xrm_String ) {
if ( p->type != P_STRING ) {
fprintf ( stderr, "Option: %s needs to be set with a string.\n", option->name );
g_warning ( "Option: %s needs to be set with a string.", option->name );
return;
}
if ( ( option )->mem != NULL ) {
@ -383,7 +383,7 @@ static void __config_parser_set_property ( XrmOption *option, const Property *p
}
else if ( option->type == xrm_Number ) {
if ( p->type != P_INTEGER ) {
fprintf ( stderr, "Option: %s needs to be set with a number.\n", option->name );
g_warning ( "Option: %s needs to be set with a number.", option->name );
return;
}
*( option->value.snum ) = p->value.i;
@ -391,7 +391,7 @@ static void __config_parser_set_property ( XrmOption *option, const Property *p
}
else if ( option->type == xrm_SNumber ) {
if ( p->type != P_INTEGER ) {
fprintf ( stderr, "Option: %s needs to be set with a number.\n", option->name );
g_warning ( "Option: %s needs to be set with a number.", option->name );
return;
}
*( option->value.num ) = (unsigned int ) ( p->value.i );
@ -399,7 +399,7 @@ static void __config_parser_set_property ( XrmOption *option, const Property *p
}
else if ( option->type == xrm_Boolean ) {
if ( p->type != P_BOOLEAN ) {
fprintf ( stderr, "Option: %s needs to be set with a boolean.\n", option->name );
g_warning ( "Option: %s needs to be set with a boolean.", option->name );
return;
}
*( option->value.num ) = ( p->value.b );