Allow setup of verbose logging from environment variable.

This commit is contained in:
Michael Drake 2012-11-05 17:01:41 +00:00
parent 36f23e424e
commit 621721417d
2 changed files with 25 additions and 1 deletions

View File

@ -788,9 +788,30 @@ int main(int argc, char** argv)
{
char path[40];
int length;
char logging_env[2];
os_var_type type;
int used = -1; /* slightly better with older OSLib versions */
os_error *error;
setbuf(stderr, NULL);
/* Consult NetSurf$Logging environment variable to decide if logging
* is required. */
error = xos_read_var_val_size("NetSurf$Logging", 0, os_VARTYPE_STRING,
&used, NULL, &type);
if (error != NULL || type != os_VARTYPE_STRING || used != -2) {
verbose_log = 1;
} else {
error = xos_read_var_val("NetSurf$Logging", logging_env,
sizeof(logging_env), 0, os_VARTYPE_STRING,
&used, NULL, &type);
if (error != NULL || logging_env[0] != '0') {
verbose_log = 1;
} else {
verbose_log = 0;
}
}
/* Pass a NULL pointer for Messages path, because until the Choices
* are loaded in netsurf_init, we don't know the Messages path. */
netsurf_init(&argc, &argv, "NetSurf:Choices", NULL);

View File

@ -9,6 +9,9 @@ Set NetSurf$ForceVars 1
/<Obey$Dir>.!Boot
UnSet NetSurf$ForceVars
| Configure logging. Set 1 to enable, or 0 to suppress.
Set NetSurf$Logging 1
| Detect if NetSurf is already running and, if so, force the
| current instance to open a new window. Then stop this script.
Set Alias$NetSurfRunning UnSet Alias$NetSurfRunning|mUnSet NetSurf$Running|mObey
@ -110,7 +113,7 @@ CDir <Wimp$ScrapDir>.WWW.NetSurf
FontInstall NetSurf:Resources.Fonts.
WIMPSLOT
Run <NetSurf$Dir>.!RunImage -v %*0 2><Wimp$ScrapDir>.WWW.NetSurf.Log
Run <NetSurf$Dir>.!RunImage %*0 2><Wimp$ScrapDir>.WWW.NetSurf.Log
| Uninstall NetSurf-specific fonts
FontRemove NetSurf:Resources.Fonts.