diff options
| author | 2009-08-19 01:24:48 +0200 | |
|---|---|---|
| committer | 2009-08-19 01:24:48 +0200 | |
| commit | d23a2142685b943c4a944ae28d6658c4f562e79e (patch) | |
| tree | 090d7a62f88151daf02bdf4b076b4908f81e7b1e /usbmuxd/main.c | |
| parent | f3cc57a74fa9647565a920ce03889084ca28c6b0 (diff) | |
| download | usbmuxd-d23a2142685b943c4a944ae28d6658c4f562e79e.tar.gz usbmuxd-d23a2142685b943c4a944ae28d6658c4f562e79e.tar.bz2 | |
Logging fixes, change default loglevel to LL_WARNING
Diffstat (limited to 'usbmuxd/main.c')
| -rw-r--r-- | usbmuxd/main.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/usbmuxd/main.c b/usbmuxd/main.c index 579a21f..ec52ce0 100644 --- a/usbmuxd/main.c +++ b/usbmuxd/main.c | |||
| @@ -235,7 +235,7 @@ static void usage() | |||
| 235 | printf("usage: usbmuxd [options]\n"); | 235 | printf("usage: usbmuxd [options]\n"); |
| 236 | printf("\t-h|--help Print this message.\n"); | 236 | printf("\t-h|--help Print this message.\n"); |
| 237 | printf("\t-v|--verbose Be verbose (use twice or more to increase).\n"); | 237 | printf("\t-v|--verbose Be verbose (use twice or more to increase).\n"); |
| 238 | printf("\t-f|--foreground Do not daemonize (implies a verbosity of 4).\n"); | 238 | printf("\t-f|--foreground Do not daemonize (implies one -v).\n"); |
| 239 | printf("\t-d|--drop-privileges Drop privileges after startup.\n"); | 239 | printf("\t-d|--drop-privileges Drop privileges after startup.\n"); |
| 240 | printf("\t-u|--udev Run in udev operation mode.\n"); | 240 | printf("\t-u|--udev Run in udev operation mode.\n"); |
| 241 | printf("\t-x|--exit Tell a running instance to exit.\n"); | 241 | printf("\t-x|--exit Tell a running instance to exit.\n"); |
| @@ -310,9 +310,10 @@ int main(int argc, char *argv[]) | |||
| 310 | argv += optind; | 310 | argv += optind; |
| 311 | 311 | ||
| 312 | if (!foreground) { | 312 | if (!foreground) { |
| 313 | verbose += LL_WARNING; | ||
| 313 | log_enable_syslog(); | 314 | log_enable_syslog(); |
| 314 | } else { | 315 | } else { |
| 315 | verbose += LL_INFO; | 316 | verbose += LL_NOTICE; |
| 316 | } | 317 | } |
| 317 | 318 | ||
| 318 | /* set log level to specified verbosity */ | 319 | /* set log level to specified verbosity */ |
| @@ -336,20 +337,22 @@ int main(int argc, char *argv[]) | |||
| 336 | if (lock.l_pid && !kill(lock.l_pid, 0)) { | 337 | if (lock.l_pid && !kill(lock.l_pid, 0)) { |
| 337 | usbmuxd_log(LL_NOTICE, "sending signal %d to instance with pid %d", exit_signal, lock.l_pid); | 338 | usbmuxd_log(LL_NOTICE, "sending signal %d to instance with pid %d", exit_signal, lock.l_pid); |
| 338 | if (kill(lock.l_pid, exit_signal) < 0) { | 339 | if (kill(lock.l_pid, exit_signal) < 0) { |
| 339 | usbmuxd_log(LL_ERROR, "Error: could not deliver signal %d to pid %d", exit_signal, lock.l_pid); | 340 | usbmuxd_log(LL_FATAL, "Error: could not deliver signal %d to pid %d", exit_signal, lock.l_pid); |
| 340 | } | 341 | } |
| 341 | res = 0; | 342 | res = 0; |
| 342 | goto terminate; | 343 | goto terminate; |
| 343 | } else { | 344 | } else { |
| 344 | usbmuxd_log(LL_ERROR, "Error: could not determine pid of the other running instance!"); | 345 | usbmuxd_log(LL_ERROR, "Could not determine pid of the other running instance!"); |
| 345 | res = -1; | 346 | res = -1; |
| 346 | goto terminate; | 347 | goto terminate; |
| 347 | } | 348 | } |
| 348 | } else { | 349 | } else { |
| 349 | usbmuxd_log(LL_NOTICE, | ||
| 350 | "another instance is already running (pid %d). exiting.", lock.l_pid); | ||
| 351 | if (!opt_udev) { | 350 | if (!opt_udev) { |
| 351 | usbmuxd_log(LL_ERROR, "Another instance is already running (pid %d). exiting.", lock.l_pid); | ||
| 352 | res = -1; | 352 | res = -1; |
| 353 | } else { | ||
| 354 | usbmuxd_log(LL_NOTICE, "Another instance is already running (pid %d). exiting.", lock.l_pid); | ||
| 355 | res = 0; | ||
| 353 | } | 356 | } |
| 354 | goto terminate; | 357 | goto terminate; |
| 355 | } | 358 | } |
| @@ -357,7 +360,7 @@ int main(int argc, char *argv[]) | |||
| 357 | } | 360 | } |
| 358 | 361 | ||
| 359 | if (opt_exit) { | 362 | if (opt_exit) { |
| 360 | usbmuxd_log(LL_NOTICE, "no running instance found, none killed. exiting."); | 363 | usbmuxd_log(LL_NOTICE, "No running instance found, none killed. exiting."); |
| 361 | goto terminate; | 364 | goto terminate; |
| 362 | } | 365 | } |
| 363 | 366 | ||
| @@ -392,7 +395,7 @@ int main(int argc, char *argv[]) | |||
| 392 | lock.l_start = 0; | 395 | lock.l_start = 0; |
| 393 | lock.l_len = 0; | 396 | lock.l_len = 0; |
| 394 | if (fcntl(fileno(lfd), F_SETLK, &lock) == -1) { | 397 | if (fcntl(fileno(lfd), F_SETLK, &lock) == -1) { |
| 395 | usbmuxd_log(LL_ERROR, "ERROR: lockfile locking failed!"); | 398 | usbmuxd_log(LL_FATAL, "Lockfile locking failed!"); |
| 396 | log_disable_syslog(); | 399 | log_disable_syslog(); |
| 397 | exit(EXIT_FAILURE); | 400 | exit(EXIT_FAILURE); |
| 398 | } | 401 | } |
| @@ -428,9 +431,9 @@ int main(int argc, char *argv[]) | |||
| 428 | usb_shutdown(); | 431 | usb_shutdown(); |
| 429 | device_shutdown(); | 432 | device_shutdown(); |
| 430 | client_shutdown(); | 433 | client_shutdown(); |
| 431 | terminate: | ||
| 432 | usbmuxd_log(LL_NOTICE, "Shutdown complete"); | 434 | usbmuxd_log(LL_NOTICE, "Shutdown complete"); |
| 433 | 435 | ||
| 436 | terminate: | ||
| 434 | log_disable_syslog(); | 437 | log_disable_syslog(); |
| 435 | 438 | ||
| 436 | if(res < 0) | 439 | if(res < 0) |
