diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-09-27 19:01:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-09-27 19:01:04 +0000 |
commit | 383eec1895fff4a83f26bb8244d86571dd5baef9 (patch) | |
tree | dc6eccf68932c71785ee86d688ebebeda2ac4025 /src/util | |
parent | 195267a6ac380d106d9409aa296885251d102c8e (diff) | |
download | gnunet-383eec1895fff4a83f26bb8244d86571dd5baef9.tar.gz gnunet-383eec1895fff4a83f26bb8244d86571dd5baef9.zip |
reducing error messages about missing configuration options by introducing new helper functions to print them uniformly
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/common_logging.c | 39 | ||||
-rw-r--r-- | src/util/gnunet-config.c | 8 |
2 files changed, 43 insertions, 4 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 6161d0c6d..23749dd99 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -1190,6 +1190,45 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) | |||
1190 | 1190 | ||
1191 | 1191 | ||
1192 | /** | 1192 | /** |
1193 | * Log error message about missing configuration option. | ||
1194 | * | ||
1195 | * @param kind log level | ||
1196 | * @param section section with missing option | ||
1197 | * @param option name of missing option | ||
1198 | */ | ||
1199 | void | ||
1200 | GNUNET_log_config_missing (enum GNUNET_ErrorType kind, | ||
1201 | const char *section, | ||
1202 | const char *option) | ||
1203 | { | ||
1204 | GNUNET_log (kind, | ||
1205 | _("Configuration fails to specify option `%s' in section `%s'!\n"), | ||
1206 | option, | ||
1207 | section); | ||
1208 | } | ||
1209 | |||
1210 | |||
1211 | /** | ||
1212 | * Log error message about invalid configuration option value. | ||
1213 | * | ||
1214 | * @param kind log level | ||
1215 | * @param section section with invalid option | ||
1216 | * @param option name of invalid option | ||
1217 | * @param required what is required that is invalid about the option | ||
1218 | */ | ||
1219 | void | ||
1220 | GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, | ||
1221 | const char *section, | ||
1222 | const char *option, | ||
1223 | const char *required) | ||
1224 | { | ||
1225 | GNUNET_log (kind, | ||
1226 | _("Configuration specifies invalid value for option `%s' in section `%s': %s\n"), | ||
1227 | option, section, required); | ||
1228 | } | ||
1229 | |||
1230 | |||
1231 | /** | ||
1193 | * Initializer | 1232 | * Initializer |
1194 | */ | 1233 | */ |
1195 | void __attribute__ ((constructor)) GNUNET_util_cl_init () | 1234 | void __attribute__ ((constructor)) GNUNET_util_cl_init () |
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index c91153f69..78c93c3b8 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c | |||
@@ -106,8 +106,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
106 | if (GNUNET_OK != | 106 | if (GNUNET_OK != |
107 | GNUNET_CONFIGURATION_get_value_filename (cfg, section, option, &value)) | 107 | GNUNET_CONFIGURATION_get_value_filename (cfg, section, option, &value)) |
108 | { | 108 | { |
109 | fprintf (stderr, _("No value for option `%s' in section `%s'\n"), | 109 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
110 | option, section); | 110 | section, option); |
111 | ret = 3; | 111 | ret = 3; |
112 | return; | 112 | return; |
113 | } | 113 | } |
@@ -117,8 +117,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
117 | if (GNUNET_OK != | 117 | if (GNUNET_OK != |
118 | GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &value)) | 118 | GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &value)) |
119 | { | 119 | { |
120 | fprintf (stderr, _("No value for option `%s' in section `%s'\n"), | 120 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
121 | option, section); | 121 | section, option); |
122 | ret = 3; | 122 | ret = 3; |
123 | return; | 123 | return; |
124 | } | 124 | } |