summaryrefslogtreecommitdiffstats
path: root/source/history.c
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/history.c
parentba9e1fb92a3d4428252f36e8df0dc77cd3874179 (diff)
Consolidate logging
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source/history.c')
-rw-r--r--source/history.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/history.c b/source/history.c
index 25cfcb00..f9e6422c 100644
--- a/source/history.c
+++ b/source/history.c
@@ -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;
}