79
#ifdef INDICATOR_APPLET
80
#define LOG_FILE_NAME "indicator-applet.log"
82
#ifdef INDICATOR_APPLET_SESSION
83
#define LOG_FILE_NAME "indicator-applet-session.log"
85
#ifdef INDICATOR_APPLET_COMPLETE
86
#define LOG_FILE_NAME "indicator-applet-complete.log"
88
GOutputStream * log_file = NULL;
397
log_to_file_cb (GObject * source_obj, GAsyncResult * result, gpointer user_data)
404
log_to_file (const gchar * domain, GLogLevelFlags level, const gchar * message, gpointer data)
406
if (log_file == NULL) {
407
GError * error = NULL;
408
gchar * filename = g_build_path(g_get_user_cache_dir(), LOG_FILE_NAME, NULL);
409
GFile * file = g_file_new_for_path(filename);
412
if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
413
GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
414
g_file_make_directory_with_parents(cachedir, NULL, &error);
417
g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
422
g_file_delete(file, NULL, NULL);
424
GFileIOStream * io = g_file_create_readwrite(file,
425
G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
426
NULL, /* cancelable */
429
g_error("Unable to replace file: %s", error->message);
433
log_file = g_io_stream_get_output_stream(G_IO_STREAM(io));
436
gchar * outputstring = g_strdup_printf("%s\n", message);
437
g_output_stream_write_async(log_file,
438
outputstring, /* data */
439
strlen(outputstring), /* length */
440
G_PRIORITY_LOW, /* priority */
441
NULL, /* cancelable */
442
log_to_file_cb, /* callback */
443
outputstring); /* data */
382
449
applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data)