summaryrefslogtreecommitdiff
path: root/xfce4-session/xfsm-global.c
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2014-09-28 17:43:30 +0300
committerEric Koegel <eric.koegel@gmail.com>2014-09-28 17:51:01 +0300
commit970249c095f31eaeb8f7bb4bb5f835c669c37e57 (patch)
tree3e69259ebe928fcd25571ae28135a821f495bbb9 /xfce4-session/xfsm-global.c
parent401c276c6035784fdd5104b83a743baaec65f5a2 (diff)
downloadxfce4-session-970249c095f31eaeb8f7bb4bb5f835c669c37e57.tar.gz
Expand usage of xfsm_verbose for debugging
This patch: 1) Documents the XFSM_VERBOSE environment variable in the man page. 2) Changes xfsm_verbose's output from a timestamp to the usual func, file, line, message format used in other Xfce programs. 3) Uses xfsm_verbose in more places to help aid in debugging. 4) Saves the last xfsm run in a .last extension, so there's always the current session log and the last one to compare to.
Diffstat (limited to 'xfce4-session/xfsm-global.c')
-rw-r--r--xfce4-session/xfsm-global.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/xfce4-session/xfsm-global.c b/xfce4-session/xfsm-global.c
index 05f8d80a..6368a9a7 100644
--- a/xfce4-session/xfsm-global.c
+++ b/xfce4-session/xfsm-global.c
@@ -73,25 +73,44 @@ xfsm_enable_verbose (void)
}
}
+gboolean
+xfsm_is_verbose_enabled (void)
+{
+ return verbose;
+}
void
-xfsm_verbose_real (const gchar *format, ...)
+xfsm_verbose_real (const char *func,
+ const char *file,
+ int line,
+ const char *format,
+ ...)
{
static FILE *fp = NULL;
gchar *logfile;
va_list valist;
- GTimeVal tv;
if (G_UNLIKELY (fp == NULL))
{
logfile = xfce_get_homefile (".xfce4-session.verbose-log", NULL);
+
+ /* rename an existing log file to -log.last */
+ if (logfile && g_file_test (logfile, G_FILE_TEST_EXISTS))
+ {
+ gchar *oldlogfile = g_strdup_printf ("%s.last", logfile);
+ if (oldlogfile)
+ {
+ rename (logfile, oldlogfile);
+ g_free (oldlogfile);
+ }
+ }
+
fp = fopen (logfile, "w");
g_free (logfile);
+ fprintf(fp, "log file opened\n");
}
- g_get_current_time(&tv);
- fprintf(fp, "[%10lu] ", tv.tv_sec);
-
+ fprintf (fp, "TRACE[%s:%d] %s(): ", file, line, func);
va_start (valist, format);
vfprintf (fp, format, valist);
fflush (fp);