diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-02 04:56:04 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-02 04:56:04 +0800 |
commit | b2cda1d0c6d44f53f71bad9e256f41188677dfba (patch) | |
tree | 65bd7560e802baf1740482ae48b952dc5c5957fc /e-util/e-logger.c | |
parent | e52986f4225cbe8496043da74ca250521d244705 (diff) | |
download | gsoc2013-evolution-b2cda1d0c6d44f53f71bad9e256f41188677dfba.tar.gz gsoc2013-evolution-b2cda1d0c6d44f53f71bad9e256f41188677dfba.tar.zst gsoc2013-evolution-b2cda1d0c6d44f53f71bad9e256f41188677dfba.zip |
Merge revisions 36016:36533 from trunk.
svn path=/branches/kill-bonobo/; revision=36534
Diffstat (limited to 'e-util/e-logger.c')
-rw-r--r-- | e-util/e-logger.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/e-util/e-logger.c b/e-util/e-logger.c index 9e46daeeaf..88f3a24327 100644 --- a/e-util/e-logger.c +++ b/e-util/e-logger.c @@ -60,7 +60,8 @@ static gpointer parent_class; static gboolean logger_flush (ELogger *logger) { - fflush (logger->priv->fp); + if (logger->priv->fp) + fflush (logger->priv->fp); logger->priv->timer = 0; return FALSE; @@ -91,6 +92,9 @@ logger_set_name (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); } @@ -136,7 +140,8 @@ logger_finalize (GObject *object) if (logger->priv->timer) g_source_remove (logger->priv->timer); logger_flush (logger); - fclose (logger->priv->fp); + if (logger->priv->fp) + fclose (logger->priv->fp); g_free (logger->priv->name); 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); logger_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; } |