Add --log-file/ -l switch to log to a file
This commit is contained in:
parent
b48817f04c
commit
5ab09ee552
1 changed files with 50 additions and 0 deletions
|
@ -1868,6 +1868,47 @@ midori_clear_offline_appcache_cb (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_log_to_file (const gchar* log_domain,
|
||||||
|
GLogLevelFlags log_level,
|
||||||
|
const gchar* message,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
FILE* logfile = fopen ((const char*)user_data, "a");
|
||||||
|
gchar* level_name = "";
|
||||||
|
|
||||||
|
switch (log_level)
|
||||||
|
{
|
||||||
|
/* skip irrelevant flags */
|
||||||
|
case G_LOG_LEVEL_MASK:
|
||||||
|
case G_LOG_FLAG_FATAL:
|
||||||
|
case G_LOG_FLAG_RECURSION:
|
||||||
|
|
||||||
|
case G_LOG_LEVEL_ERROR:
|
||||||
|
level_name = "ERROR";
|
||||||
|
break;
|
||||||
|
case G_LOG_LEVEL_CRITICAL:
|
||||||
|
level_name = "CRITICAL";
|
||||||
|
break;
|
||||||
|
case G_LOG_LEVEL_WARNING:
|
||||||
|
level_name = "WARNING";
|
||||||
|
break;
|
||||||
|
case G_LOG_LEVEL_MESSAGE:
|
||||||
|
level_name = "MESSAGE";
|
||||||
|
break;
|
||||||
|
case G_LOG_LEVEL_INFO:
|
||||||
|
level_name = "INFO";
|
||||||
|
break;
|
||||||
|
case G_LOG_LEVEL_DEBUG:
|
||||||
|
level_name = "DEBUG";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (logfile, "%s %s: %s\n",
|
||||||
|
log_domain ? log_domain : "Midori", level_name, message);
|
||||||
|
fclose (logfile);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char** argv)
|
char** argv)
|
||||||
|
@ -1879,6 +1920,7 @@ main (int argc,
|
||||||
gboolean back_from_crash;
|
gboolean back_from_crash;
|
||||||
gboolean run;
|
gboolean run;
|
||||||
gchar* snapshot;
|
gchar* snapshot;
|
||||||
|
gchar* logfile;
|
||||||
gboolean execute;
|
gboolean execute;
|
||||||
gboolean help_execute;
|
gboolean help_execute;
|
||||||
gboolean version;
|
gboolean version;
|
||||||
|
@ -1921,6 +1963,8 @@ main (int argc,
|
||||||
/* i18n: CLI: Close tabs, clear private data, open starting page */
|
/* i18n: CLI: Close tabs, clear private data, open starting page */
|
||||||
N_("Reset Midori after SECONDS seconds of inactivity"), N_("SECONDS") },
|
N_("Reset Midori after SECONDS seconds of inactivity"), N_("SECONDS") },
|
||||||
#endif
|
#endif
|
||||||
|
{ "log-file", 'l', 0, G_OPTION_ARG_FILENAME, &logfile,
|
||||||
|
N_("Redirects console warnings to the specified FILENAME"), N_("FILENAME")},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
GString* error_messages;
|
GString* error_messages;
|
||||||
|
@ -1996,6 +2040,7 @@ main (int argc,
|
||||||
diagnostic_dialog = FALSE;
|
diagnostic_dialog = FALSE;
|
||||||
run = FALSE;
|
run = FALSE;
|
||||||
snapshot = NULL;
|
snapshot = NULL;
|
||||||
|
logfile = NULL;
|
||||||
execute = FALSE;
|
execute = FALSE;
|
||||||
help_execute = FALSE;
|
help_execute = FALSE;
|
||||||
version = FALSE;
|
version = FALSE;
|
||||||
|
@ -2113,6 +2158,11 @@ main (int argc,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (logfile)
|
||||||
|
{
|
||||||
|
g_log_set_default_handler (midori_log_to_file, (gpointer)logfile);
|
||||||
|
}
|
||||||
|
|
||||||
sokoke_register_privacy_item ("page-icons", _("Website icons"),
|
sokoke_register_privacy_item ("page-icons", _("Website icons"),
|
||||||
G_CALLBACK (midori_clear_page_icons_cb));
|
G_CALLBACK (midori_clear_page_icons_cb));
|
||||||
/* i18n: Logins and passwords in websites and web forms */
|
/* i18n: Logins and passwords in websites and web forms */
|
||||||
|
|
Loading…
Reference in a new issue