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
|
||||
|
||||
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
|
||||
main (int argc,
|
||||
char** argv)
|
||||
|
@ -1879,6 +1920,7 @@ main (int argc,
|
|||
gboolean back_from_crash;
|
||||
gboolean run;
|
||||
gchar* snapshot;
|
||||
gchar* logfile;
|
||||
gboolean execute;
|
||||
gboolean help_execute;
|
||||
gboolean version;
|
||||
|
@ -1921,6 +1963,8 @@ main (int argc,
|
|||
/* i18n: CLI: Close tabs, clear private data, open starting page */
|
||||
N_("Reset Midori after SECONDS seconds of inactivity"), N_("SECONDS") },
|
||||
#endif
|
||||
{ "log-file", 'l', 0, G_OPTION_ARG_FILENAME, &logfile,
|
||||
N_("Redirects console warnings to the specified FILENAME"), N_("FILENAME")},
|
||||
{ NULL }
|
||||
};
|
||||
GString* error_messages;
|
||||
|
@ -1996,6 +2040,7 @@ main (int argc,
|
|||
diagnostic_dialog = FALSE;
|
||||
run = FALSE;
|
||||
snapshot = NULL;
|
||||
logfile = NULL;
|
||||
execute = FALSE;
|
||||
help_execute = FALSE;
|
||||
version = FALSE;
|
||||
|
@ -2113,6 +2158,11 @@ main (int argc,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (logfile)
|
||||
{
|
||||
g_log_set_default_handler (midori_log_to_file, (gpointer)logfile);
|
||||
}
|
||||
|
||||
sokoke_register_privacy_item ("page-icons", _("Website icons"),
|
||||
G_CALLBACK (midori_clear_page_icons_cb));
|
||||
/* i18n: Logins and passwords in websites and web forms */
|
||||
|
|
Loading…
Reference in a new issue