aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-09-26 16:56:37 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-09-26 16:56:37 +0800
commit6df1e6d99608781b9e37b02e2a8c28074823ca7f (patch)
tree978426f08a85827b0fd00f28b8f5ac5e7949fcb4 /e-util
parentb2fc0d756d4f9f6ebd631e39f763eeba1f30c704 (diff)
downloadgsoc2013-evolution-6df1e6d99608781b9e37b02e2a8c28074823ca7f.tar
gsoc2013-evolution-6df1e6d99608781b9e37b02e2a8c28074823ca7f.tar.gz
gsoc2013-evolution-6df1e6d99608781b9e37b02e2a8c28074823ca7f.tar.bz2
gsoc2013-evolution-6df1e6d99608781b9e37b02e2a8c28074823ca7f.tar.lz
gsoc2013-evolution-6df1e6d99608781b9e37b02e2a8c28074823ca7f.tar.xz
gsoc2013-evolution-6df1e6d99608781b9e37b02e2a8c28074823ca7f.tar.zst
gsoc2013-evolution-6df1e6d99608781b9e37b02e2a8c28074823ca7f.zip
** Fix for bug #535248
2008-09-26 Milan Crha <mcrha@redhat.com> ** Fix for bug #535248 * e-logger.c: (flush_logfile), (logger_set_component), (logger_finalize), (e_logger_log), (e_logger_get_logs): Check if log file has been opened successfully before using it. svn path=/trunk/; revision=36456
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog8
-rw-r--r--e-util/e-logger.c17
2 files changed, 21 insertions, 4 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 04024ea454..1afe42f512 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,11 @@
+2008-09-26 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #535248
+
+ * e-logger.c: (flush_logfile), (logger_set_component),
+ (logger_finalize), (e_logger_log), (e_logger_get_logs):
+ Check if log file has been opened successfully before using it.
+
2008-09-24 Sankar P <psankar@novell.com>
License Changes
diff --git a/e-util/e-logger.c b/e-util/e-logger.c
index 0c95520fe8..9db0ca0e37 100644
--- a/e-util/e-logger.c
+++ b/e-util/e-logger.c
@@ -60,7 +60,8 @@ static gpointer parent_class;
static gboolean
flush_logfile (ELogger *logger)
{
- fflush (logger->priv->fp);
+ if (logger->priv->fp)
+ fflush (logger->priv->fp);
logger->priv->timer = 0;
return FALSE;
@@ -81,6 +82,9 @@ logger_set_component (ELogger *logger,
logger->priv->fp = g_fopen (logger->priv->logfile, "w");
logger->priv->timer = 0;
+ if (!logger->priv->fp)
+ g_warning ("%s: Failed to open log file '%s' for writing.", G_STRFUNC, logger->priv->logfile ? logger->priv->logfile : "[null]");
+
g_free (temp);
}
@@ -126,7 +130,8 @@ logger_finalize (GObject *object)
if (logger->priv->timer)
g_source_remove (logger->priv->timer);
flush_logfile (logger);
- fclose (logger->priv->fp);
+ if (logger->priv->fp)
+ fclose (logger->priv->fp);
g_free (logger->priv->component);
g_free (logger->priv->logfile);
@@ -230,6 +235,9 @@ e_logger_log (ELogger *logger,
g_return_if_fail (primary != NULL);
g_return_if_fail (secondary != NULL);
+ if (!logger->priv->fp)
+ return;
+
fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, primary);
fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, secondary);
set_dirty (logger);
@@ -247,11 +255,12 @@ e_logger_get_logs (ELogger *logger,
g_return_if_fail (func != NULL);
/* Flush everything before we get the logs */
- fflush (logger->priv->fp);
+ if (logger->priv->fp)
+ fflush (logger->priv->fp);
fp = g_fopen (logger->priv->logfile, "r");
if (!fp) {
- fprintf (stderr, "Cannot open log file '%s' for reading! No flush yet?\n", logger->priv->logfile ? logger->priv->logfile : "[null]");
+ g_warning ("%s: Cannot open log file '%s' for reading! No flush yet?\n", G_STRFUNC, logger->priv->logfile ? logger->priv->logfile : "[null]");
return;
}