summaryrefslogtreecommitdiffstats
path: root/tools/idevicesyslog.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/idevicesyslog.c')
-rw-r--r--tools/idevicesyslog.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 5600be2..a0e641d 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -480,7 +480,10 @@ static void print_usage(int argc, char **argv, int is_error)
480 " -h, --help prints usage information\n" 480 " -h, --help prints usage information\n"
481 " -d, --debug enable communication debugging\n" 481 " -d, --debug enable communication debugging\n"
482 " -v, --version prints version information\n" 482 " -v, --version prints version information\n"
483 " --no-colors disable colored output\n" 483 " --no-colors disable colored output\n"
484 " -o, --output FILE write to FILE instead of stdout\n"
485 " (existing FILE will be overwritten)\n"
486 " --colors force writing colored output, e.g. for --output\n"
484 "\n" 487 "\n"
485 "FILTER OPTIONS:\n" 488 "FILTER OPTIONS:\n"
486 " -m, --match STRING only print messages that contain STRING\n" 489 " -m, --match STRING only print messages that contain STRING\n"
@@ -508,6 +511,7 @@ int main(int argc, char *argv[])
508 int exclude_filter = 0; 511 int exclude_filter = 0;
509 int include_kernel = 0; 512 int include_kernel = 0;
510 int exclude_kernel = 0; 513 int exclude_kernel = 0;
514 int force_colors = 0;
511 int c = 0; 515 int c = 0;
512 const struct option longopts[] = { 516 const struct option longopts[] = {
513 { "debug", no_argument, NULL, 'd' }, 517 { "debug", no_argument, NULL, 'd' },
@@ -525,6 +529,8 @@ int main(int argc, char *argv[])
525 { "no-kernel", no_argument, NULL, 'K' }, 529 { "no-kernel", no_argument, NULL, 'K' },
526 { "quiet-list", no_argument, NULL, 1 }, 530 { "quiet-list", no_argument, NULL, 1 },
527 { "no-colors", no_argument, NULL, 2 }, 531 { "no-colors", no_argument, NULL, 2 },
532 { "colors", no_argument, NULL, 3 },
533 { "output", required_argument, NULL, 'o' },
528 { "version", no_argument, NULL, 'v' }, 534 { "version", no_argument, NULL, 'v' },
529 { NULL, 0, NULL, 0} 535 { NULL, 0, NULL, 0}
530 }; 536 };
@@ -536,7 +542,7 @@ int main(int argc, char *argv[])
536 signal(SIGPIPE, SIG_IGN); 542 signal(SIGPIPE, SIG_IGN);
537#endif 543#endif
538 544
539 while ((c = getopt_long(argc, argv, "dhu:nxt:T:m:e:p:qkKv", longopts, NULL)) != -1) { 545 while ((c = getopt_long(argc, argv, "dhu:nxt:T:m:e:p:qkKo:v", longopts, NULL)) != -1) {
540 switch (c) { 546 switch (c) {
541 case 'd': 547 case 'd':
542 idevice_set_debug_level(1); 548 idevice_set_debug_level(1);
@@ -638,6 +644,22 @@ int main(int argc, char *argv[])
638 case 2: 644 case 2:
639 term_colors_set_enabled(0); 645 term_colors_set_enabled(0);
640 break; 646 break;
647 case 3:
648 force_colors = 1;
649 break;
650 case 'o':
651 if (!*optarg) {
652 fprintf(stderr, "ERROR: --output option requires an argument!\n");
653 print_usage(argc, argv, 1);
654 return 2;
655 } else {
656 if (freopen(optarg, "w", stdout) == NULL) {
657 fprintf(stderr, "ERROR: Failed to open output file '%s' for writing: %s\n", optarg, strerror(errno));
658 return 1;
659 }
660 term_colors_set_enabled(0);
661 }
662 break;
641 case 'v': 663 case 'v':
642 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION); 664 printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
643 return 0; 665 return 0;
@@ -647,6 +669,10 @@ int main(int argc, char *argv[])
647 } 669 }
648 } 670 }
649 671
672 if (force_colors) {
673 term_colors_set_enabled(1);
674 }
675
650 if (include_kernel > 0 && exclude_kernel > 0) { 676 if (include_kernel > 0 && exclude_kernel > 0) {
651 fprintf(stderr, "ERROR: -k and -K cannot be used together.\n"); 677 fprintf(stderr, "ERROR: -k and -K cannot be used together.\n");
652 print_usage(argc, argv, 1); 678 print_usage(argc, argv, 1);