mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-19 05:07:56 +00:00
Rename config option 'log.stderr' to 'log.console'
Because Android <stdio.h> defines 'stderr' as a macro...
This commit is contained in:
parent
f7fc63c452
commit
ec481e5f0f
@ -288,7 +288,7 @@ END_STRUCT_ASSIGN
|
|||||||
|
|
||||||
STRUCT(log)
|
STRUCT(log)
|
||||||
SUB_STRUCT(log_format_file, file,,)
|
SUB_STRUCT(log_format_file, file,,)
|
||||||
SUB_STRUCT(log_format, stderr,, important)
|
SUB_STRUCT(log_format, console,, important)
|
||||||
SUB_STRUCT(log_format, android,, android)
|
SUB_STRUCT(log_format, android,, android)
|
||||||
END_STRUCT
|
END_STRUCT
|
||||||
|
|
||||||
|
17
log.c
17
log.c
@ -157,7 +157,7 @@ static void _log_iterator_advance_to_android(_log_iterator *it)
|
|||||||
|
|
||||||
static void _log_iterator_advance_to_stderr(_log_iterator *it)
|
static void _log_iterator_advance_to_stderr(_log_iterator *it)
|
||||||
{
|
{
|
||||||
it->config = &config.log.stderr;
|
it->config = &config.log.console;
|
||||||
it->state = &state_stderr;
|
it->state = &state_stderr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ static int _log_enabled(_log_iterator *it)
|
|||||||
if (_log_file == NO_FILE)
|
if (_log_file == NO_FILE)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (it->config == &config.log.stderr) {
|
else if (it->config == &config.log.console) {
|
||||||
_open_log_stderr();
|
_open_log_stderr();
|
||||||
if (logfile_stderr == NULL || logfile_stderr == NO_FILE)
|
if (logfile_stderr == NULL || logfile_stderr == NO_FILE)
|
||||||
return 0;
|
return 0;
|
||||||
@ -224,7 +224,7 @@ static void _log_prefix(_log_iterator *it, int level)
|
|||||||
it->xpf = XPRINTF_STRBUF(&_android_strbuf);
|
it->xpf = XPRINTF_STRBUF(&_android_strbuf);
|
||||||
}
|
}
|
||||||
#endif // ANDROID
|
#endif // ANDROID
|
||||||
else if (it->config == &config.log.stderr) {
|
else if (it->config == &config.log.console) {
|
||||||
it->xpf = XPRINTF_STDIO(logfile_stderr);
|
it->xpf = XPRINTF_STDIO(logfile_stderr);
|
||||||
_log_prefix_level(it, level);
|
_log_prefix_level(it, level);
|
||||||
}
|
}
|
||||||
@ -286,11 +286,11 @@ static void _log_end_line(_log_iterator *it, int level)
|
|||||||
case LOG_LEVEL_DEBUG: alevel = ANDROID_LOG_DEBUG; break;
|
case LOG_LEVEL_DEBUG: alevel = ANDROID_LOG_DEBUG; break;
|
||||||
default: abort();
|
default: abort();
|
||||||
}
|
}
|
||||||
__android_log_print(alevel, "servald", "%s", strbuf_str(_log_android_buf));
|
__android_log_print(alevel, "servald", "%s", _log_android_buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // ANDROID
|
#endif // ANDROID
|
||||||
if (it->config == &config.log.stderr) {
|
if (it->config == &config.log.console) {
|
||||||
fputc('\n', logfile_stderr);
|
fputc('\n', logfile_stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ static void _log_flush(_log_iterator *it)
|
|||||||
if (it->config == &config_file) {
|
if (it->config == &config_file) {
|
||||||
_flush_log_file();
|
_flush_log_file();
|
||||||
}
|
}
|
||||||
else if (it->config == &config.log.stderr) {
|
else if (it->config == &config.log.console) {
|
||||||
_flush_log_stderr();
|
_flush_log_stderr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,7 +478,10 @@ static void _open_log_file(_log_iterator *it)
|
|||||||
_logs_printf_nl(serverMode ? LOG_LEVEL_WARN : LOG_LEVEL_INFO, __NOWHERE__, "No log file configured");
|
_logs_printf_nl(serverMode ? LOG_LEVEL_WARN : LOG_LEVEL_INFO, __NOWHERE__, "No log file configured");
|
||||||
} else {
|
} else {
|
||||||
// Create the new log file.
|
// Create the new log file.
|
||||||
const char *dir = dirname(strdupa(_log_file_path));
|
size_t dirsiz = strlen(_log_file_path) + 1;
|
||||||
|
char _dir[dirsiz];
|
||||||
|
strcpy(_dir, _log_file_path);
|
||||||
|
const char *dir = dirname(_dir); // modifies _dir[]
|
||||||
if (mkdirs(dir, 0700) != -1 && (_log_file = fopen(_log_file_path, "a"))) {
|
if (mkdirs(dir, 0700) != -1 && (_log_file = fopen(_log_file_path, "a"))) {
|
||||||
setlinebuf(_log_file);
|
setlinebuf(_log_file);
|
||||||
memset(it->state, 0, sizeof it->state);
|
memset(it->state, 0, sizeof it->state);
|
||||||
|
10
tests/config
10
tests/config
@ -90,13 +90,13 @@ doc_GetAll="Get all config items"
|
|||||||
test_GetAll() {
|
test_GetAll() {
|
||||||
executeOk_servald config \
|
executeOk_servald config \
|
||||||
set debug.verbose true \
|
set debug.verbose true \
|
||||||
set log.stderr.show_pid true \
|
set log.console.show_pid true \
|
||||||
set server.chdir /tmp/nothing \
|
set server.chdir /tmp/nothing \
|
||||||
set rhizome.enable no
|
set rhizome.enable no
|
||||||
executeOk_servald config get
|
executeOk_servald config get
|
||||||
assertStdoutLineCount '==' 4
|
assertStdoutLineCount '==' 4
|
||||||
assertStdoutGrep --stdout --matches=1 '^debug\.verbose=true$'
|
assertStdoutGrep --stdout --matches=1 '^debug\.verbose=true$'
|
||||||
assertStdoutGrep --stdout --matches=1 '^log\.stderr\.show_pid=true$'
|
assertStdoutGrep --stdout --matches=1 '^log\.console\.show_pid=true$'
|
||||||
assertStdoutGrep --stdout --matches=1 '^server\.chdir=/tmp/nothing$'
|
assertStdoutGrep --stdout --matches=1 '^server\.chdir=/tmp/nothing$'
|
||||||
assertStdoutGrep --stdout --matches=1 '^rhizome\.enable=no$'
|
assertStdoutGrep --stdout --matches=1 '^rhizome\.enable=no$'
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ test_DelNull() {
|
|||||||
|
|
||||||
doc_Del="Delete single config item"
|
doc_Del="Delete single config item"
|
||||||
test_Del() {
|
test_Del() {
|
||||||
executeOk_servald config set debug.verbose yes set log.stderr.show_pid true
|
executeOk_servald config set debug.verbose yes set log.console.show_pid true
|
||||||
executeOk_servald config get
|
executeOk_servald config get
|
||||||
assertStdoutLineCount '==' 2
|
assertStdoutLineCount '==' 2
|
||||||
executeOk_servald config del debug.verbose
|
executeOk_servald config del debug.verbose
|
||||||
@ -170,8 +170,8 @@ doc_DebugFlags="Debug config options affect verbosity"
|
|||||||
setup_DebugFlags() {
|
setup_DebugFlags() {
|
||||||
setup
|
setup
|
||||||
executeOk_servald config \
|
executeOk_servald config \
|
||||||
set log.stderr.level debug \
|
set log.console.level debug \
|
||||||
set log.stderr.show_pid true
|
set log.console.show_pid true
|
||||||
}
|
}
|
||||||
test_DebugFlags() {
|
test_DebugFlags() {
|
||||||
executeOk_servald echo one two three
|
executeOk_servald echo one two three
|
||||||
|
@ -23,8 +23,8 @@ source "${0%/*}/../testdefs.sh"
|
|||||||
|
|
||||||
configure_servald_server() {
|
configure_servald_server() {
|
||||||
executeOk_servald config \
|
executeOk_servald config \
|
||||||
set log.stderr.show_pid on \
|
set log.console.show_pid on \
|
||||||
set log.stderr.show_time on \
|
set log.console.show_time on \
|
||||||
set rhizome.enable No \
|
set rhizome.enable No \
|
||||||
set debug.mdprequests Yes
|
set debug.mdprequests Yes
|
||||||
}
|
}
|
||||||
@ -98,8 +98,8 @@ start_routing_instance() {
|
|||||||
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
||||||
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
||||||
set rhizome.enable No \
|
set rhizome.enable No \
|
||||||
set log.stderr.show_pid on \
|
set log.console.show_pid on \
|
||||||
set log.stderr.show_time on \
|
set log.console.show_time on \
|
||||||
set debug.mdprequests Yes
|
set debug.mdprequests Yes
|
||||||
start_servald_server
|
start_servald_server
|
||||||
wait_until interface_up
|
wait_until interface_up
|
||||||
|
@ -43,9 +43,9 @@ teardown() {
|
|||||||
# process in each instance.
|
# process in each instance.
|
||||||
configure_servald_server() {
|
configure_servald_server() {
|
||||||
executeOk_servald config \
|
executeOk_servald config \
|
||||||
set log.stderr.level debug \
|
set log.console.level debug \
|
||||||
set log.stderr.show_pid on \
|
set log.console.show_pid on \
|
||||||
set log.stderr.show_time on \
|
set log.console.show_time on \
|
||||||
set debug.dnahelper on \
|
set debug.dnahelper on \
|
||||||
set dna.helper.executable "$dnahelper" \
|
set dna.helper.executable "$dnahelper" \
|
||||||
set dna.helper.argv.1 "Hello," \
|
set dna.helper.argv.1 "Hello," \
|
||||||
|
@ -58,9 +58,9 @@ teardown() {
|
|||||||
|
|
||||||
set_server_vars() {
|
set_server_vars() {
|
||||||
executeOk_servald config \
|
executeOk_servald config \
|
||||||
set log.stderr.level debug \
|
set log.console.level debug \
|
||||||
set log.stderr.show_pid on \
|
set log.console.show_pid on \
|
||||||
set log.stderr.show_time on \
|
set log.console.show_time on \
|
||||||
set mdp.iftype.wifi.tick_ms 100 \
|
set mdp.iftype.wifi.tick_ms 100 \
|
||||||
set rhizome.enable No \
|
set rhizome.enable No \
|
||||||
set debug.overlayinterfaces Yes \
|
set debug.overlayinterfaces Yes \
|
||||||
|
@ -40,7 +40,7 @@ test_LogStderrDefault() {
|
|||||||
|
|
||||||
doc_LogStderrConfigAll="Configure all messages logged to stderr"
|
doc_LogStderrConfigAll="Configure all messages logged to stderr"
|
||||||
test_LogStderrConfigAll() {
|
test_LogStderrConfigAll() {
|
||||||
executeOk_servald config set log.stderr.level debug
|
executeOk_servald config set log.console.level debug
|
||||||
execute $servald log error 'hoopla'
|
execute $servald log error 'hoopla'
|
||||||
assertExitStatus '==' 0
|
assertExitStatus '==' 0
|
||||||
assertStderrGrep --matches=1 '^ERROR:.*hoopla$'
|
assertStderrGrep --matches=1 '^ERROR:.*hoopla$'
|
||||||
@ -54,7 +54,7 @@ test_LogStderrConfigAll() {
|
|||||||
|
|
||||||
doc_LogStderrConfigNone="Configure no messages logged to stderr"
|
doc_LogStderrConfigNone="Configure no messages logged to stderr"
|
||||||
test_LogStderrConfigNone() {
|
test_LogStderrConfigNone() {
|
||||||
executeOk_servald config set log.stderr.level none
|
executeOk_servald config set log.console.level none
|
||||||
executeOk_servald log error 'hoopla'
|
executeOk_servald log error 'hoopla'
|
||||||
assertStderrIs ''
|
assertStderrIs ''
|
||||||
executeOk_servald log warn 'buckle'
|
executeOk_servald log warn 'buckle'
|
||||||
@ -67,7 +67,7 @@ test_LogStderrConfigNone() {
|
|||||||
|
|
||||||
doc_LogFileDefault="By Default, all messages are appended to a configured file"
|
doc_LogFileDefault="By Default, all messages are appended to a configured file"
|
||||||
test_LogFileDefault() {
|
test_LogFileDefault() {
|
||||||
executeOk_servald config set log.stderr.level none
|
executeOk_servald config set log.console.level none
|
||||||
executeOk_servald config set log.file.path "$PWD/log.txt"
|
executeOk_servald config set log.file.path "$PWD/log.txt"
|
||||||
executeOk_servald log error 'hoopla'
|
executeOk_servald log error 'hoopla'
|
||||||
assertGrep --matches=1 log.txt '^ERROR:.*hoopla$'
|
assertGrep --matches=1 log.txt '^ERROR:.*hoopla$'
|
||||||
@ -87,7 +87,7 @@ test_LogFileDefault() {
|
|||||||
|
|
||||||
doc_LogFileConfigLevel="Configure level of messages appended to a configured file"
|
doc_LogFileConfigLevel="Configure level of messages appended to a configured file"
|
||||||
test_LogFileConfigLevel() {
|
test_LogFileConfigLevel() {
|
||||||
executeOk_servald config set log.stderr.level none
|
executeOk_servald config set log.console.level none
|
||||||
executeOk_servald config set log.file.level info
|
executeOk_servald config set log.file.level info
|
||||||
executeOk_servald config set log.file.path "$PWD/log.txt"
|
executeOk_servald config set log.file.path "$PWD/log.txt"
|
||||||
executeOk_servald log warn 'buckle'
|
executeOk_servald log warn 'buckle'
|
||||||
|
@ -37,8 +37,8 @@ teardown() {
|
|||||||
# Called by start_servald_instances for each instance.
|
# Called by start_servald_instances for each instance.
|
||||||
configure_servald_server() {
|
configure_servald_server() {
|
||||||
executeOk_servald config \
|
executeOk_servald config \
|
||||||
set log.stderr.show_pid on \
|
set log.console.show_pid on \
|
||||||
set log.stderr.show_time on \
|
set log.console.show_time on \
|
||||||
set debug.rhizome on \
|
set debug.rhizome on \
|
||||||
set debug.rhizome_tx on \
|
set debug.rhizome_tx on \
|
||||||
set debug.rhizome_rx on \
|
set debug.rhizome_rx on \
|
||||||
@ -450,8 +450,8 @@ setup_direct() {
|
|||||||
get_rhizome_server_port PORTA +A
|
get_rhizome_server_port PORTA +A
|
||||||
set_instance +B
|
set_instance +B
|
||||||
executeOk_servald config \
|
executeOk_servald config \
|
||||||
set log.stderr.level debug \
|
set log.console.level debug \
|
||||||
set log.stderr.show_time on \
|
set log.console.show_time on \
|
||||||
set debug.rhizome on \
|
set debug.rhizome on \
|
||||||
set debug.rhizome_tx on \
|
set debug.rhizome_tx on \
|
||||||
set debug.rhizome_rx on \
|
set debug.rhizome_rx on \
|
||||||
|
@ -39,8 +39,8 @@ start_routing_instance() {
|
|||||||
set server.interface_path "$SERVALD_VAR" \
|
set server.interface_path "$SERVALD_VAR" \
|
||||||
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
||||||
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
||||||
set log.stderr.show_pid on \
|
set log.console.show_pid on \
|
||||||
set log.stderr.show_time on \
|
set log.console.show_time on \
|
||||||
set debug.mdprequests Yes \
|
set debug.mdprequests Yes \
|
||||||
set rhizome.enable no
|
set rhizome.enable no
|
||||||
start_servald_server
|
start_servald_server
|
||||||
|
Loading…
Reference in New Issue
Block a user