diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-08 11:40:10 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-08 11:40:10 +0000 |
commit | f075da7a8927f75bc643254ead167bd9620aee1e (patch) | |
tree | c6a058da41a4e9d7ce713416d8808c7eac6cfb4f | |
parent | 3d72a11b0dcbb1ed703b6a946d8518e46466f2c5 (diff) | |
download | gnunet-f075da7a8927f75bc643254ead167bd9620aee1e.tar.gz gnunet-f075da7a8927f75bc643254ead167bd9620aee1e.zip |
- have hostname part of the log file
-rw-r--r-- | src/testbed/gnunet-service-testbed-logger.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/testbed/gnunet-service-testbed-logger.c b/src/testbed/gnunet-service-testbed-logger.c index 7f3a42be2..fd5c49ecc 100644 --- a/src/testbed/gnunet-service-testbed-logger.c +++ b/src/testbed/gnunet-service-testbed-logger.c | |||
@@ -222,6 +222,8 @@ logger_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
222 | }; | 222 | }; |
223 | char *dir; | 223 | char *dir; |
224 | char *fn; | 224 | char *fn; |
225 | char *hname; | ||
226 | size_t hname_len; | ||
225 | pid_t pid; | 227 | pid_t pid; |
226 | 228 | ||
227 | if (GNUNET_OK != | 229 | if (GNUNET_OK != |
@@ -229,14 +231,27 @@ logger_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
229 | &dir)) | 231 | &dir)) |
230 | { | 232 | { |
231 | LOG (GNUNET_ERROR_TYPE_ERROR, "Not logging directory definied. Exiting\n"); | 233 | LOG (GNUNET_ERROR_TYPE_ERROR, "Not logging directory definied. Exiting\n"); |
234 | GNUNET_SCHEDULER_shutdown (); | ||
232 | return; | 235 | return; |
233 | } | 236 | } |
234 | pid = getpid (); | 237 | pid = getpid (); |
235 | (void) GNUNET_asprintf (&fn, "%s/%jd.dat", dir, (intmax_t) pid); | 238 | hname_len = GNUNET_OS_get_hostname_max_length (); |
239 | hname = GNUNET_malloc (hname_len); | ||
240 | if (0 != gethostname (hname, hname_len)) | ||
241 | { | ||
242 | LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot get hostname. Exiting\n"); | ||
243 | GNUNET_free (hname); | ||
244 | GNUNET_SCHEDULER_shutdown (); | ||
245 | return; | ||
246 | } | ||
247 | (void) GNUNET_asprintf (&fn, "%s/%.*s_%jd.dat", dir, hname_len, hname, | ||
248 | (intmax_t) pid); | ||
249 | GNUNET_free (hname); | ||
236 | GNUNET_free (dir); | 250 | GNUNET_free (dir); |
237 | if (NULL == (bio = GNUNET_BIO_write_open (fn))) | 251 | if (NULL == (bio = GNUNET_BIO_write_open (fn))) |
238 | { | 252 | { |
239 | GNUNET_free (fn); | 253 | GNUNET_free (fn); |
254 | GNUNET_SCHEDULER_shutdown (); | ||
240 | return; | 255 | return; |
241 | } | 256 | } |
242 | GNUNET_free (fn); | 257 | GNUNET_free (fn); |