summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2017-04-15 11:58:49 +0200
committerQuentin Glidic <sardemff7+git@sardemff7.net>2017-04-15 12:07:29 +0200
commitcfbe4027bcbafe4715bbba1b36799002c719a81e (patch)
tree4811b9d0766298ea0093d5266dd7b2248359416e /source/dialogs
parentba9e1fb92a3d4428252f36e8df0dc77cd3874179 (diff)
Consolidate logging
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/combi.c7
-rw-r--r--source/dialogs/dmenu.c7
-rw-r--r--source/dialogs/drun.c17
-rw-r--r--source/dialogs/run.c14
-rw-r--r--source/dialogs/script.c8
-rw-r--r--source/dialogs/ssh.c19
-rw-r--r--source/dialogs/window.c6
7 files changed, 41 insertions, 37 deletions
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index f1e041c3..dd0cfb67 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -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;
}
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index be9b4be1..255fd720 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -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 );
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 062617c0..c16c6f2b 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -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;
}
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index b8534095..62e55150 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -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 ) );
}
}
}
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index 72594a67..52cc1a03 100644
--- a/source/dialogs/script.c
+++ b/source/dialogs/script.c
@@ -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;
}
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 0dc2d9a7..0bc277fb 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -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>
@@ -51,13 +57,6 @@
#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.
*/
#define SSH_CACHE_FILE "rofi-2.sshcache"
@@ -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 ) );
}
}
}
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 9d65aeb4..2ed4bad4 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -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
{